title: How to limit to 1 item on Left join query with JPA?
body: <p>Here's my use case :</p>
  
  <pre><code>public class User extends Model {}
  
  public class TableA extends Model {
      @OneToMany
      public List&lt;TableB&gt; tableBs;
  
      @ManyToOne
      public AnObject anObject;
  }
  
  public class TableB extends Model {
      @ManyToOne
      public TableA tableA;
  
      @ManyToOne
      public User user;
  
      public String status;
  }
  </code></pre>
  
  <p>The user get a list of TableA entries based on an instance of AnObject. I'd like to show this user if TableA is new or not.</p>
  
  <p>(note that TableB is acting like a n:n table for User and TableA, I can't integrate it to TableA)</p>
  
  <p>To say if it is new, it depends on TableB. For that, I have two options :</p>
  
  <ul>
  <li>Either creating TableB when I create TableA, but with the status at NEW or No</li>
  <li>Or not creating TableB for that user. If the link is missing for that user, that mean it's new. (doing it, I could remove the column status)</li>
  </ul>
  
  <p>(actions depends on "new", it's not just a label to show).</p>
  
  <p>Now, in my JPA request, how can I indicate if, for that member, TableA entry is new or not ?</p>
  
  <p>The simple way would be to get the list of TableA, and then go through the List to check if there is the User in it (a method like <code>isUserInTableB(User user)</code>)</p>
  
  <p>But is it possible to do it with JPA, for example by having only one item in the List, that would be the User, or empty if this user is not linked ?</p>
  
  <p>(I hope I'm clear, it's not so much in my head :/)</p>
  
  <p>Thank you really much for your help, I appreciate!</p>