我的数据源配置如下:
development {
dataSource {
dbCreate = "validate"
url = "jdbc:sqlserver://myservername"
}
}
我的 SQL Server“myservername”有一个数据库“products”,其中有一个“dbo”拥有的表“inventory”。这是我的 Inventory 类映射:
static mapping = {
table 'products.dbo.inventory'
version false
columns {
id column: 'itemKey'
itemId column: 'itemId'
inactive column: 'inactive'
}
}
当我尝试运行该应用程序时,我收到此错误:
嵌套异常是 org.hibernate.HibernateException: Missing table: products.dbo.inventory
此外,当我将 dbCreate 从“验证”更改为“更新”或任何其他时,它工作正常。
任何想法为什么?
在此先感谢,
斯库德
编辑以回答问题 -
我将更改合并到我的对象中,但仍然出现错误。这是我的对象:
class Inventory {
Integer id
String itemId
String description
Boolean inactive
static mapping = {
table 'products.dbo.inventory'
version false
columns {
id column: 'itemKey'
itemId column: 'itemId'
description column: 'description'
inactive column: 'inactive'
}
}
static constraints = {
itemId (maxSize: 30)
description (maxSize: 100)
}
static hasMany = [productInventoryDefaults: ProductInventoryDefaults, productTreeNodes: ProductTreeNodes]
String toString() {
return this.itemId
}
}
和表:
CREATE TABLE [dbo].[inventory](
[itemKey] [int] NOT NULL,
[itemId] [varchar](30) NOT NULL,
[description] [varchar](100) NOT NULL,
[inactive] [bit] NOT NULL,
CONSTRAINT [PK_Inventory] PRIMARY KEY CLUSTERED
(
[itemKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO