JPQL for a Unidirectional OneToMany <p>I need a jpql query for my Spring repository interface method, to retrieve all Posts for a given Semester.</p> <pre><code>@LazyCollection(LazyCollectionOption.FALSE) @OneToMany(cascade = CascadeType.MERGE) @JoinTable ( name = "semester_post", joinColumns = {@JoinColumn(name = "semester_id", referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "post_id", referencedColumnName = "id", unique = true)} ) private List&lt;PostEntity&lt;?&gt;&gt; posts = new ArrayList&lt;&gt;(); </code></pre> <p>PostEntity doesn't have a reference to Semester, and I do not want to add one, because I plan to use this PostEntity for other things than Semester. Maybe I'll have another class (let's say Group) which will also have a OneToMany of PostEntity (like the one in Semester)</p> <p><strong>So, how do I write this SQL query as a JPQL one ?</strong></p> <pre><code>select * from posts join semester_post on semester_post.post_id = posts.id where semester_post.semester_id = 1; </code></pre> <p>My repository</p> <pre><code>public interface PostRepository extends JpaRepository&lt;PostEntity, Long&gt; { String QUERY = "SELECT p FROM PostEntity p ... where semester = :semesterId"; @Query(MY_QUERY) public List&lt;PostEntity&gt; findBySemesterOrderByModifiedDateDesc(@Param("semesterId") Long semesterId); </code></pre>