title: JPA one to many relationship - @transactional - get children collection
body: <p>I want to get the children collection of the owner entity of a <strong>one to many</strong> relationship.
  I have those two entities : </p>
  
  <pre><code>@Entity
  @Table(name = "commande")
  public class Commande implements Serializable {
  
  private static final long serialVersionUID = 1L;
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  
  @Column(name = "name")
  private String name;
  
  @OneToMany(mappedBy = "commande")
  @JoinColumn(name= "papa_id")
  @JsonIgnore
  private Set&lt;Piece&gt; pieces = new HashSet&lt;&gt;();
  
  
  
  @Entity
  @Table(name = "piece")
  public class Piece implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      @Column(name = "ref")
      private String ref;
  
      @ManyToOne
      private Commande commande; 
  </code></pre>
  
  <p>And the resource : </p>
  
  <pre><code>@RequestMapping(value = "/papas/{id}",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  @Transactional
  public ResponseEntity&lt;Papa&gt; getPapa(@PathVariable Long id) {
      log.debug("REST request to get Papa : {}", id);
      Papa papa = papaRepository.findOne(id);
      papa.getEnfants().size();
      ...
  }
  </code></pre>
  
  <p>I had to put <strong>@Transactional</strong> in order to make the .size() work (otherwise I have an exception).
  It works.
  But if in another method I delete one Enfant entity, then if I call getPapa again, I am getting an error durint .size() :</p>
  
  <pre><code>Unable to find com.myapp.stagiaireproject.domain.Enfant with id 3
  </code></pre>
  
  <p>Is it a problem of a transaction not closed?</p>