我的问题与是否可以在 grails 中禁用域类的持久性有关/或相同 ?
我正在使用 grails 2.2.1,我尝试通过放置静态 mapWith = "none" gorm 创建数据库表来关闭域类,调用 .save() 实际上会将一个条目放入数据库。所以 mapWith 标志对我没有任何作用。我也找不到有关 mapWith 标志的任何文档。Grails 2 中有替代品吗?
9 月 16 日更新代码
package test
class Person {
String name
static constraints = {
}
static mapping = {
version false
tablePerHierarchy false
table 'psn'
}
}
-------------------
package test
class Employer extends Person{
static mapWith = 'none'
String title
static constraints = {
}
static mapping = {
version false
tablePerHierarchy false
table 'emplyr'
}
}
---------
package test
class Employee extends Person{
String description
static constraints = {
}
static mapping = {
version false
tablePerHierarchy false
table 'emplyee'
}
}
我认为 Employer 不应被视为域对象。但是,当我执行 Person.list() 时,显示了以下 sql:
Hibernate: select this_.id as id0_0_, this_.name as name0_0_, this_1_.description as descript2_1_0_, this_2_.title as title2_0_, case when this_1_.id is not null then 1 when this_2_.id is not null then 2 when this_.id is not null then 0 end as clazz_0_ from psn this_ left outer join emplyee this_1_ on this_.id=this_1_.id left outer join emplyr this_2_ on this_.id=this_2_.id limit ?
Hibernate: select count(*) as y0_ from psn this_ left outer join emplyee this_1_ on this_.id=this_1_.id left outer join emplyr this_2_ on this_.id=this_2_.id
为什么要加入emplyr????我的目的是在将其标记为“无”时消除此表连接。难道我做错了什么?