[jboss-user] [EJB 3.0] - Re: Bug? @Inheritance(strategy=JOINED) AND @DiscriminatorVal

fhh do-not-reply at jboss.com
Mon Jan 29 16:45:38 EST 2007


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


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008016#4008016

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008016



More information about the jboss-user mailing list