openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pawel Veselov <>
Subject NULL maps from merged entities
Date Tue, 24 Jan 2012 20:11:18 GMT

Typically, when an entity has a relationship expressed as @OneToMany or
@ManyToMany in a form of a collection, or a map, the collection or a map
will be empty (not null), if there are no referenced objects (I believe
JPA2.0 explicitly states that). So far, I haven't been having any problems
with this, but I did find that the map will be null on a newly merged

        ETest test = em.find(ETest.class, req.getParameter(P_ID));
        ETest newTest = new ETest();
        newTest = em.merge(newTest);
        newTest = em.merge(newTest);
        newTest.getUsedAgents().putAll(test.getUsedAgents()); // NPE

the getUsedAgents() returns null. The entity code (abridged) is:

public class ETest {
    @ManyToMany(cascade = CascadeType.ALL)
    private Map<String, EAgent> usedAgents;
    public Map<String, EAgent> getUsedAgents() {
        return usedAgents;

I believe that would be a bug.

This is OpenJPA 2.1.1, entities enhanced with PCEnhancer, no funny stuff in
p.xml, just the entity list.

Thank you,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message