-->
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: Query vs. mapped ID field
PostPosted: Sun Nov 21, 2010 11:11 pm 
Newbie

Joined: Fri Mar 27, 2009 4:29 pm
Posts: 7
Hi -
Is it possible to query against a local column value if that column is the key in a mapped relationship?

i.e. Option contains
Code:
        <many-to-one name="optionType" column="optionTypeId" not-null="false" />


I want all Options where Option.optionTypeId == 0. This should left-outer join the mapped OptionType (because in this database, 0 means record does not exist). Result would be Option with a null OptionType.

I've tried a number of things, but of course the Option.optionTypeId is not really a recognized field, independent its mapping. Should a SQLQuery be able to get around this? So far I have not gotten that to work.

Thanks for ideas.


Top
 Profile  
 
 Post subject: Re: Query vs. mapped ID field
PostPosted: Mon Nov 22, 2010 6:21 pm 
Newbie

Joined: Fri Mar 27, 2009 4:29 pm
Posts: 7
It seems like it should be possible but the solution I went with was just to add dummy data with the ID of 0.

This would be done in SQL like
Code:
select o.*, ot.*
from option o
left outer join optionType ot on o.optionTypeId = ot.optionTypeId
where o.optionTypeId = 0


I started going down the route of using a SQLQuery but it couldn't find my entity for some reason (yes I followed http://docs.jboss.org/hibernate/core/3. ... l#d0e13646) and I ran out of time to mess with it.

Can anyone answer if this should be possible at least?


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.