This content has been marked as final.
Show 1 reply
-
1. Re: Bug? @Inheritance(strategy=JOINED) AND @DiscriminatorVal
fhh Jan 29, 2007 4:45 PM (in response to fhh)Sorry, I have found the Hibernate bug describing this: http://opensource.atlassian.com/projects/hibernate/browse/ANN-140?page=all
(It is amazing that you always find the bug report only after you tried to describe the problem yourself.)
Since I don't know anything about the hibernate sources I will not even try to supply the 3k lines mentioned in the bug report but I have a dirty little workaround:@Entity @Inheritance(strategy=JOINED) //@DiscriminatorColumn(name="YOUR_DTYPE") public abstract class parent { @Id Integer id; @Column(name="YOUR_DTYPE",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) { } }
It is double plus unbeautiful but it works. Should this ever be fixed you can simply remove the workaround and everything should work as expected.
Regards
Felix