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.