-->
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.  [ 4 posts ] 
Author Message
 Post subject: one-to-one bug?
PostPosted: Tue Jul 11, 2006 7:03 pm 
Newbie

Joined: Tue Jul 11, 2006 6:38 pm
Posts: 2
I have a one-to-one relationship between Vehicle and Device with unique foreign key.
table vehicles
vehicle_id
...
table devices
device_id pk
vehicle_id


For the Device object I have this:
<many-to-one name="Vehicle" column="vehicle_id" class="Vehicle" unique="true" cascade="none"/>

and for the Vehicle object I have this:
<one-to-one name="Device" class="Device" property-ref="Vehicle" />

I'm trying to find all Vehicle objects that do not have associated Device object using this:
vehicles = session.CreateCriteria(typeof(Vehicle))
.Add(Expression.IsNull("Device"))
.List();

This returns empty set because the generated SQL is wrong. This is it:
SELECT ..... FROM
vehicles this
left outer join devices device1_ on this.vehicle_id=device1_.vehicle_id
WHERE this.vehicle_id is null

The Where clause here should be:
WHERE device1_.vehicle_id is null

Am I doing something wrong?


Hibernate version:
1.02


Last edited by nopethanks on Thu Jul 20, 2006 2:36 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Still no answer
PostPosted: Thu Jul 20, 2006 2:36 pm 
Newbie

Joined: Tue Jul 11, 2006 6:38 pm
Posts: 2
Can anyone help or explain what is the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 7:33 pm 
Newbie

Joined: Thu Oct 09, 2003 11:07 pm
Posts: 7
I believe I had the same problem as described above. I found a suitable workaround offered in the "Advanced Problems" FAQ under the heading "The query language IS NULL syntax won't work with a one-to-one association!"

The solution worked for me! Hope this helps. I swore I would post an answer if I found one. Hope this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 27, 2007 12:51 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It's probably a bug, but try version 1.2.0, 1.0.2 is quite old.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.