Hello All,
We are using Hibernate 3.x with annotations and entity manager. We have defined a few @inheritence joined relationships to support a legacy data model which are working fine during persistence and retrieval using JPQL named queries.
The problem that I am having is when I try to use native sql and map the data to a result set which may result in polymorphic relationships.
For example, here is a simplified example of what I am trying to do:
Base Class:
Code:
@Entity
@Table(name = "base")
@Inheritance(strategy=InheritanceType.JOINED)
public class Base {
....
}
Derived Class:
Code:
@Entity
@Table(name="derived")
@PrimaryKeyJoinColumn(name="oid")
public class Derived extends Base {
...
}
I have tried multiple ways to map, here is one example :
Code:
<named-native-query name="TEST"
result-set-mapping="RESULT-SET">
<query>
SELECT b.*, d.*
FROM base b, derived d
WHERE b.oid = ? and
b.oid = d.oid (+)
</query>
</named-native-query>
<sql-result-set-mapping name="RESULT-SET">
<entity-result entity-class="Base">
<entity-result entity-class="Derived"/>
</sql-result-set-mapping>
I have also tried using a discriminator-column and a few other variations with no luck. As I mentioned, the named-query works fine but not the pure sql.
Thanks alot for your time.
Regards,
Kurt