-->
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.  [ 2 posts ] 
Author Message
 Post subject: force outer-join with map collection index in where clause
PostPosted: Wed Oct 01, 2008 7:27 am 
Newbie

Joined: Mon Aug 27, 2007 11:11 pm
Posts: 8
Location: Brisbane
I have a class mapped as follows...

<class name="equipment" table="MSF600">

<id name="equipNo" column="EQUIP_NO"/>

<map name="nameplate" table="MSF6A4" outer-join="true" fetch="join">
<key column="EQUIP_NO"/>
<map-key column="ATTRIB_NAME" type="string"/>
<element column="ATTRIB_VALUE" type="string"/>
</map>

</class>

The map collection allows me to perform queries on the equipment as follows...

from equipment where nameplate["TARIFF"] not in ('RU', 'BG')

This works fine up until I want to do a query like this...

from equipment where nameplate["TARIFF"] is null or nameplate["TARIFF"] not in ('RU', 'BG')

The problem happens because hibernate performs an implicit inner join with the MSF6A4 table when it detects a nameplate[""] in the where clause. If the "TARIFF" nameplate doesn't exist, the join will not match and so no results will be returned.

I know I can use...

from equipment where "TARIFF" not in indices(nameplate)

but still doesn't work in a combined where clause like this..

from equipment where "TARIFF" not in indices(nameplate) or nameplate["TARIFF"] not in ('RU', 'BG')

because as soon as the nameplate["TARIFF"] appears, hibernate does the implicit inner join to MSF6A4 again and finds no results.

I think my problem would be solved if I could force hibernate to perform an outer-join on the MSF6AF table.

Is this possible? Is there some other way to get this to work?


Top
 Profile  
 
 Post subject: solution
PostPosted: Thu Oct 02, 2008 11:34 pm 
Newbie

Joined: Mon Aug 27, 2007 11:11 pm
Posts: 8
Location: Brisbane
Jeez..these forums are a great help. Haven't had one semi-difficult question answered on this forum.

Anyway the solution is to modify source to make hibernate add the (+) to the joined key columns to force oracle to do an outer-join. There seems to be no support for this feature out of the box.


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

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.