title: LazyInitializationException with OneToMany in the simpliest way
body: <p>I'm using Hibernate with jpa and I'm getting LazyInizializationException trying to do a very simple thing. I know what does LazyInizializationException means but I can't understand why it comes while i'm doing everything in the most common and simple way. This is the "one" side of the relationship:</p>
  
  <pre><code>@Entity
  public class User implements Serializable{
  
  @Id @GeneratedValue
  private int idUser;
  
  private String name;
  private String surname;
  private String username;
  
  @OneToMany(mappedBy="user")
  private List&lt;Device&gt; dev;
  
  ...getters and setters...
  </code></pre>
  
  <p>and this is the "Many" side:</p>
  
  <pre><code>@Entity
  public class Device implements Serializable {
  
  @Id @GeneratedValue
  private int idDevice;
  
  private String brand;
  private String model;
  
  @ManyToOne
  @JoinColumn(name="user_fk")
  private User user;
  
  ...getters and setters...
  </code></pre>
  
  <p>the jUnit test that throws the exception is:</p>
  
  <pre><code>@Test
  public void testLazyUserSnd() {
      User u = uDao.getUser(2);
      List&lt;Device&gt; devList = u.getDev();
      Device aDevice = devList.get(0); // &lt;--- Here the exception is thrown
      aDevice.getModel();
  </code></pre>
  
  <p>I made the relationship as explained in the <a href="http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/entity.html" rel="nofollow">Hibernate Documentation</a>. Any hint? Am I making some big and stupid mistakes?</p>