-->
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: Help using Hibernate named native queries with inheritence
PostPosted: Fri May 18, 2007 4:14 pm 
Beginner
Beginner

Joined: Wed Jan 03, 2007 7:47 pm
Posts: 23
Location: Richardson, Texas
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


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.