I'm working on a Grails project, Grails version: 2.2.0.
I have these classes:
public abstract class A {}
public class B extends A {}
public class C extends A {}
For now, everything is OK
class A is in: src/groovy so in DB I have two tables B & C.
now I add a new class:
public class D{
A aa
}
now that no longer works because hibernate doesn't cognize the Type A.
One solution is to omit the abstract term but that allows instantiation of A object which is not so right!
Does any one have an idea about how fix this problem?
thank you
The problem is this: GORM/Hibernate must be able to instantiate the domain class properties (except for the transient ones, of course). Because of this, a property cannot be of an abstract type. Interfaces don't work for the same reason.
To keep inheritance, unfortunately you'll have to do that not so right thing: drop the abstract and make A
a domain class.