我的问题与/或相同 Is it possible in grails to disable persistence of a domain class?
我正在使用grails 2.2.1,我尝试通过put来关闭域类 static 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'
}
}
我认为雇主不应被视为域对象。但是,当我执行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 ?????我的目的是在标记为“none”时消除此表连接。我做错了吗?