title: Spring boot JPA how to query a @OneToMany relationship given one object in the many relationship
body: <p>I've seen a few related questions but I can't seem to find the right answer for what I'm trying to do.
  I have two tables Jobs and Workers, a job can have many workers, simplified entity</p>
  <pre><code>@Entity
  @Table(name = &quot;jobs&quot;)
  data class Job(
      @Id
      @Type(type = &quot;pg-uuid&quot;)
      val id: UUID = UUID.randomUUID()
  ) {
      @ManyToOne
      var office: Office? = null
  
      @OneToMany(targetEntity = Worker::class)
      var requests: MutableList&lt;Worker&gt; = mutableListOf()
  }
  </code></pre>
  <p>I want to be able to fetch a list of jobs for a specific worker</p>
  <p>I've tried a few queries native and not, but trying to just do it by namedMethods now, whatever works I guess to be honest here is what seems like it should work in my jobs repo</p>
  <pre><code>@Repository
  interface JobsRepo : CrudRepository&lt;Job, UUID&gt; {
  
      @Query(&quot;SELECT j FROM Job j WHERE id = ?1&quot;)
      fun findJobById(id: UUID): Job?
  
      @Query(&quot;SELECT j FROM Job j WHERE office_id = ?1&quot;)
      fun findJobsByOffice(id: UUID): List&lt;Job&gt;?
  
      @Modifying
      @Transactional
      @Query(&quot;UPDATE jobs SET job_status = 4 WHERE job_status = 1 AND start_time &lt; ?1&quot;, nativeQuery = true)
      fun expireJobs(date: Date)
  
      fun findByRequests_Worker(worker: Worker): List&lt;Job&gt;?
  
  }
  </code></pre>
  <p>I'm not really sure how to query the array property</p>
  <pre><code>requests
  </code></pre>
  <p>with in input of one worker. I tried querying the UUID of the worker too since thats whats in the join table</p>
  <p>JPA creates a join table with both foreign keys the table is</p>
  <pre><code>jobs_requests
  </code></pre>
  <p>and columns</p>
  <pre><code>job_id UUID
  requests_id UUID
  </code></pre>