Reputation: 28419
I have two tables joined together with entities like this (entities anonymized, and trimmed of irrelevant properties):
Email - Email_ID - Title - Body (hibernate uses a Body_ID field here)
Body - Body_ID - Body_Text
I'd like to retrieve all Email entries that do not have an associated Body row (ie, Body_ID is null). What HQL would do this?
Upvotes: 0
Views: 215
Reputation: 26574
assuming email can have only one body:
from Email e where e.body is null
Upvotes: 1
Reputation: 7195
Assuming you have an Email object with a @OneToOne or @ManyToOne to Body:
select e from Email as e where e.body is null
Upvotes: 1