| Using a correlation with an inverse assocation in a subquery will cause invalid SQL to be generated. Consider the simple model
@Entity class Person {
@OneToMany(mappedBy = "author")
Set<Article> articles;
}
@Entity class Article {
@ManyToOne
Person author;
}
When querying like SELECT ... FROM Person p WHERE EXISTS (SELECT ... FROM p.articles) it will generate SQL like select ... from person person0_ where exists (select articles1_.id from left outer join article article2_ on articles1_.id=article2_.article_id where person0_.id=articles1_.author_id). |