LAZY fetch association (list) updated when the owning entity is merged in EAP 6

Solution Verified - Updated -

Issue

  • An association is declared between Member and Address using FetchType.LAZY
public class Member implements Serializable {
    @Id
    @GeneratedValue
    private Long id;
    ...
    @ManyToMany(fetch=FetchType.LAZY, targetEntity=Address.class)
    @JoinTable(name="tbl_member_address",
                joinColumns = @JoinColumn(name="member_id"),
                inverseJoinColumns = @JoinColumn(name="address_id")
    )
    private List<Address> addresses = new ArrayList<Address>();
  • An instance of Member is instantiated using the ID of an existing entity
  • After modifying various properties (not including the association property), the new instance is merged using the EntityManager
  • The association between the Member and Address entities is severed (the association rows are deleted from the tbl_member_address table)

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 6
  • Hibernate 4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.