This content has been marked as final.
Show 4 replies
-
1. Re: Joined Inheritance Strategy Problem
waynebaylor Aug 9, 2007 10:00 AM (in response to grdzeli_kaci)The InheritanceType.JOINED is a "table per subclass" strategy. So you don't need a discriminator, which is probably why it was null.
-
2. Re: Joined Inheritance Strategy Problem
grdzeli_kaci Aug 10, 2007 2:24 AM (in response to grdzeli_kaci)"waynebaylor" wrote:
The InheritanceType.JOINED is a "table per subclass" strategy. So you don't need a discriminator, which is probably why it was null.
i did what you say, but problem not resolved. -
3. Re: Joined Inheritance Strategy Problem
fhh Aug 10, 2007 4:55 AM (in response to grdzeli_kaci)Hibernate only uses the discrimnator value if it is really needed (single table strategy). Since the class type for the strategy joined is clear by itself the discriminator value will be null. You can use the following hack to work around this:
/* * This is workaround for a hibernate bug: * -> http://opensource.atlassian.com/projects/hibernate/browse/ANN-140?page=all */ @Column(name="DISCRIMINATOR",length=31) public String getDiscriminatorValue() { DiscriminatorValue discriminatorValueAnnotation = this.getClass().getAnnotation(DiscriminatorValue.class); if (discriminatorValueAnnotation != null) { return discriminatorValueAnnotation.value(); } return this.getClass().getSimpleName(); } public void setDiscriminatorValue(String dummy) { }
You will have to tweak it to use an integer as the discriminator value.
Regards
Felix -
4. Re: Joined Inheritance Strategy Problem
grdzeli_kaci Aug 10, 2007 9:53 AM (in response to grdzeli_kaci)it works, fine,
thank you very much.