[jboss-user] [EJB 3.0] - Re: Joined Inheritance Strategy Problem

fhh do-not-reply at jboss.com
Fri Aug 10 04:55:37 EDT 2007


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

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

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



More information about the jboss-user mailing list