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....