I have no ideas how to do it using Hibernate Criteria
SELECT *
FROM Table_A A
LEFT JOIN Table_B B
ON A.Key = B.Key
WHERE B.Key IS NULL
there is Hibernate mapping like
@Entity
class A{
@Id
@Column(name = "ID")
private String ID;
... // fields
}
@Entity
class B{
... // fields
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "A_ID", referencedColumnName = "ID")
@Cascade(CascadeType.DETACH)
private A a;
... // fields
}
So I need to get list of all A which are not referred by B
Not tried it before, but something like this should work:
This is of course in HQL
Criteria might look like this: