-->
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: Hibernate mapping problem
PostPosted: Tue Jun 17, 2008 5:29 am 
Newbie

Joined: Tue Jun 17, 2008 5:21 am
Posts: 1
Hi everybody! I have a Problem with a strange mapping in hibernate: lets say i have junctions and roads. Every road starts and ends at a junction and there may be n roads at each junction. So my junction table has the fields junctionId, name. My road table has the fields roadId, startJunction, destinationJunction. The fields startJunction and destinationJunction are foreign keys to junction.junctionId.

So here is my Problem: I want to have a set of roads for each of my junctions in the java classes and I want to do this in the mapping file. So this is what I have done: in my mapping for the junction class I mapped a set like this:
Code:
<set name="road" inverse="true">
         <key column="roadId"/>
         <one-to-many class="Road"/>
         <loader query-ref="roads"/>
</set>


and build a query like this one:

Code:
   <sql-query name="roads">
      <load-collection alias="road" role="road"/>
      SELECT {roads.*}
      FROM Road road
      WHERE startJunction = :junction OR destinationJunction = :junction
   </sql-query> 

hibernate does not complain but never returns anything....


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.