-->
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: wrong sql generated when accessing a one-to-one relation
PostPosted: Tue Aug 03, 2010 1:15 pm 
Newbie

Joined: Wed Jun 27, 2007 1:10 am
Posts: 12
Code:
@Entity
public class Post implements java.io.Serializable {
...

   @OneToOne(cascade = CascadeType.ALL)
   @PrimaryKeyJoinColumn
   public Car getCar() {
      return this.car;
   }
}

@Entity
public class Car implements java.io.Serializable {

...
   @OneToOne
   @PrimaryKeyJoinColumn
   public Post getPost() {
      return this.post;
   }
}



I need to find all the posts that do not have a car associated. I use the following:

Code:
List<Post> posts = sess.createQuery("from Post p where p.car is null").list();


The sql generated turned out to be
Code:
select post0_.id as id0_, post0_.date as date0_, post0_.description as descript3_0_, post0_.title as title0_, post0_.url as url0_ from Post post0_ where post0_.id is null



Can anyone explain why that's the case?

Thanks.


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.