title: JPA refresh entity
body: <p>I have two tables in my database <code>USERS</code> and <code>ADDRESSES</code>, each user can have many addresses. </p>
  
  <p>I have build entity classes with NetBeans wizard, and it create the classes well:</p>
  
  <pre><code>@Entity
  @Table(name = "USERS")
  @XmlRootElement
  public class User implements Serializable {
  
      private static final long serialVersionUID = 1L;
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(name = "ID")
      private Integer id;
      // Some fields.......
      @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
      private Collection&lt;Address&gt; addressCollection;
  
      public User() {
      }
  
      // Getters and Setters.......
  }
  
  @Entity
  @Table(name = "ADDRESSES")
  @XmlRootElement
  public class Address implements Serializable {
  
      private static final long serialVersionUID = 1L;
      @EmbeddedId
      protected AddressPK addressPK;
      // Some fields.......
      @JoinColumn(name = "USER_ID", referencedColumnName = "ID", insertable = false, updatable = false)
      @ManyToOne(optional = false)
      private User user;
  
      public Address() {
      }
  
      // Getters and Setters.......
  }
  
  @Embeddable
  public class AddressPK implements Serializable {
  
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(name = "ID")
      private int id;
      @Basic(optional = false)
      @NotNull
      @Column(name = "USER_ID")
      private int userId;
  
      public AddressPK() {
      }
  }
  </code></pre>
  
  <p>In the session I save the <code>User</code> instance of the current logged in user. But the <code>User</code>'s <code>addressCollection</code> never updates when I change the database like:</p>
  
  <pre><code>Address newAddr = new Address();
  // Sets values to newAddr......
  AddressFacade addrDao = new AddressFacade();
  addrDao.create(newAddr); // Succeeded
  
  LoginManager.getCurrentUser().getAddressCollection(); // Returns the old address list.
  </code></pre>
  
  <p>How can I refresh the current user's instance to get the correct <code>addressCollection</code>?</p>