title: Best way to persist JPA entities in Play framework
body: <p>I'm new to JPA, let alone JPA in Play, so I'm wondering what is the best way to save my objects with a <code>@ManyToOne</code> relationship to multiple classes.</p>
  
  <p>The UserJump class is defined as follows:</p>
  
  <pre><code>@Entity
  public class UserJump extends Model{
      @ManyToOne
      public User user;
      @ManyToOne
      public JumpSession jumpSession;
      public String parachuteUID;
      public String notes;
      public int status;
  </code></pre>
  
  <p>}</p>
  
  <p>The relationship to UserJump is defined from inside JumpSession by :</p>
  
  <pre><code>@OneToMany(mappedBy="jumpSession")
  public List&lt;UserJump&gt; userJumps;
  </code></pre>
  
  <p>Likewise in the User class:</p>
  
  <pre><code>@OneToMany(mappedBy="user")
  public List&lt;UserJump&gt; userJumps;
  </code></pre>
  
  <p>Here's how I'm saving things right now:</p>
  
  <pre><code>JumpSession jumpSession = new JumpSession();
  //...Code here to fill in jumpSession...
  jumpSession.save();
  
  UserJump userJump;
  for(String jumperUID : jumpers)
  {
      userJump = new UserJump();
      userJump.jumpSession = jumpSession;
      userJump.user = User.findById(jumperUID);
      userJump.status = 1;
      userJump.save();
  }
  </code></pre>
  
  <p>It seems to me that there should be a way to save those UserJump objects in a List called userJumps and then do <code>jumpSession.userJumps = userJumps</code>, then <code>jumpSession.save()</code> and it should persist all the UserJump objects.  Is there a way to do this?  And which way is the best way to do this?  </p>