My question is related to/or identical to Is it possible in grails to disable persistence of a domain class?
I am using grails 2.2.1 where I tried to turn off a domain class by putting static mapWith = "none" gorm creates the database table, and calling .save() will actually put an entry to the database. So the mapWith flag did nothing for me. I also cannot find any documentation regarding the mapWith flag. Is there a replacement in Grails 2?
Update on sept 16 with code
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'
}
}
I would assume Employer should not be treated as a domain object. However, when I perform, a Person.list(), this sql was shown:
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
Why would it join emplyr????? My purpose is to eliminate this table join when this is mark as "none". Am I doing something wrong?