Grails 域错误
Grails domain error
这是我第一次使用 Grails,我定义了以下域 class
package ing2015
class Product {
String name, description, location
Category category
Subcategory subcategory
static belongsTo = [Category, Subcategory]
Date date
static constraints = {
name(blank:false)
date (blank:false)
description(blank:false)
location(blank:false)
}
}
package ing2015
class Category {
String name
static hasmany=[product: Product, subcategory: Subcategory]
static constraints = {
name(blank:false)
}
}
package ing2015
class Subcategory {
String name
Category category
static belongsTo = Category
static HasMany = [product : Product]
static constraints = {
}
}
但是当我尝试 运行-app,或为这些域生成任何控制器时,它向我显示此错误
| Error Error loading plugin manager: No property found for name [product] for class [class ing2015.Subcategory] (Use --stacktrace to see the full trace)
Error |
我找不到问题,在此之前,控制台向我显示了无法创建 table "product" 和 "category"[=14 之类的东西=]
Edit
我只是解决了将"HasMany"更改为"hasMany"的问题。
但现在我不知道为什么控制台会显示这个
objc[1024]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
| Error 2015-10-11 01:47:41,066 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table image drop constraint FK_mm4cmvteo84wq24upfvucdy08 if exists
| Error 2015-10-11 01:47:41,069 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Tabla "IMAGE" no encontrada
Table "IMAGE" not found; SQL statement:
alter table image drop constraint FK_mm4cmvteo84wq24upfvucdy08 if exists [42102-176]
| Error 2015-10-11 01:47:41,069 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table product drop constraint FK_rlaghtegr0yx2c1q1s6nkqjlh if exists
| Error 2015-10-11 01:47:41,070 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Tabla "PRODUCT" no encontrada
Table "PRODUCT" not found; SQL statement:
alter table product drop constraint FK_rlaghtegr0yx2c1q1s6nkqjlh if exists [42102-176]
| Error 2015-10-11 01:47:41,070 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table product drop constraint FK_lmq2wxehhih47uva0peyk8v8g if exists
| Error 2015-10-11 01:47:41,071 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Tabla "PRODUCT" no encontrada
Table "PRODUCT" not found; SQL statement:
alter table product drop constraint FK_lmq2wxehhih47uva0peyk8v8g if exists [42102-176]
| Error 2015-10-11 01:47:41,071 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table subcategory drop constraint FK_dglte9qeu8l5fhggto4loyegg if exists
| Error 2015-10-11 01:47:41,071 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Tabla "SUBCATEGORY" no encontrada
Table "SUBCATEGORY" not found; SQL statement:
alter table subcategory drop constraint FK_dglte9qeu8l5fhggto4loyegg if exists [42102-176
我不确定
static HasMany
被 grails 正确读取 *(hasMany 必须是),顺便说一句,这里的代码对我有用:
class Category {
String name
static hasMany= [product: Product, subcategories: Subcategory]
static constraints = {
name(blank:false)
}
}
class Subcategory {
String name
Category category
static belongsTo = [category : Category]
static hasMany = [product : Product]
static constraints = {
}
}
这是我第一次使用 Grails,我定义了以下域 class
package ing2015
class Product {
String name, description, location
Category category
Subcategory subcategory
static belongsTo = [Category, Subcategory]
Date date
static constraints = {
name(blank:false)
date (blank:false)
description(blank:false)
location(blank:false)
}
}
package ing2015
class Category {
String name
static hasmany=[product: Product, subcategory: Subcategory]
static constraints = {
name(blank:false)
}
}
package ing2015
class Subcategory {
String name
Category category
static belongsTo = Category
static HasMany = [product : Product]
static constraints = {
}
}
但是当我尝试 运行-app,或为这些域生成任何控制器时,它向我显示此错误
| Error Error loading plugin manager: No property found for name [product] for class [class ing2015.Subcategory] (Use --stacktrace to see the full trace)
Error |
我找不到问题,在此之前,控制台向我显示了无法创建 table "product" 和 "category"[=14 之类的东西=]
Edit
我只是解决了将"HasMany"更改为"hasMany"的问题。 但现在我不知道为什么控制台会显示这个
objc[1024]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
| Error 2015-10-11 01:47:41,066 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table image drop constraint FK_mm4cmvteo84wq24upfvucdy08 if exists
| Error 2015-10-11 01:47:41,069 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Tabla "IMAGE" no encontrada
Table "IMAGE" not found; SQL statement:
alter table image drop constraint FK_mm4cmvteo84wq24upfvucdy08 if exists [42102-176]
| Error 2015-10-11 01:47:41,069 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table product drop constraint FK_rlaghtegr0yx2c1q1s6nkqjlh if exists
| Error 2015-10-11 01:47:41,070 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Tabla "PRODUCT" no encontrada
Table "PRODUCT" not found; SQL statement:
alter table product drop constraint FK_rlaghtegr0yx2c1q1s6nkqjlh if exists [42102-176]
| Error 2015-10-11 01:47:41,070 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table product drop constraint FK_lmq2wxehhih47uva0peyk8v8g if exists
| Error 2015-10-11 01:47:41,071 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Tabla "PRODUCT" no encontrada
Table "PRODUCT" not found; SQL statement:
alter table product drop constraint FK_lmq2wxehhih47uva0peyk8v8g if exists [42102-176]
| Error 2015-10-11 01:47:41,071 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table subcategory drop constraint FK_dglte9qeu8l5fhggto4loyegg if exists
| Error 2015-10-11 01:47:41,071 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Tabla "SUBCATEGORY" no encontrada
Table "SUBCATEGORY" not found; SQL statement:
alter table subcategory drop constraint FK_dglte9qeu8l5fhggto4loyegg if exists [42102-176
我不确定
static HasMany
被 grails 正确读取 *(hasMany 必须是),顺便说一句,这里的代码对我有用:
class Category {
String name
static hasMany= [product: Product, subcategories: Subcategory]
static constraints = {
name(blank:false)
}
}
class Subcategory {
String name
Category category
static belongsTo = [category : Category]
static hasMany = [product : Product]
static constraints = {
}
}