-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: problem with inheritance single per table hql
PostPosted: Tue Aug 30, 2005 11:49 am 
Newbie

Joined: Tue Aug 30, 2005 11:45 am
Posts: 1
hey,

In our project, we are currently
developing with jdk 1.5(using generics)
and we are using hibernate annotations (EJB 3.0).
We have a problem with the SQL generated in a HQL when a single per table inheritance strategy is involved.
Let me explain showing you an example. Starting from a inheritance single per table strategy
as the following example

@Entity
@Table(name="A_TABLE")
@Inheritance()
@DiscriminatorColumn(name="DISCRIMINATOR")
public abstract class A<T> implements java.io.Serializable{

private T value;

private long id;

@Id(generate=GeneratorType.AUTO)
public long getId(){

}

protected void setId(long id){
this.id = id;
}

@Transient
public T getValue(){
return value;
}

public void setValue(T value){

}

// it could appear other methods .....
}


public class StringA extends A<String>{

@Column(name="STRING_VALUE")
public String getValue(){
return super.getValue();
}
}

public class DateA extends A<java.util.Date>{

@Column(name="DATE_VALUE")
public java.util.Date getValue(){
return super.getValue();
}
}


public class NumberA extends A<Number>{

@Column(name="NUMBER_VALUE")
@Basic(temporalType=TemporalType.TIMESTAMP)
public Number getValue(){
return super.getValue();
}
}

we have formulated the following named HQL ::

select a from A as a where a.value=:value

the SQL generated by Hibernate is like this

"select a.id,{other columns} from A_TABLE where a.STRING_VALUE=?"

but for us is not enough because the parameter "value" could be in runtime a string,number or a date
and always would have a look up in STRING_VALUE column from the A_TABLE skipping the NUMBER_VALUE
and DATE_VALUE columns. We are asking if hibernate deals with this kind of feature properly.

We have try to put a formula in the StringA class (more concretly in the method getValue), but we realize that
it is not the correct solution.

thanks a lot!!

Direct trust team


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.