Community
Participate
Working Groups
Build Identifier: 2.2.0 My JPA provider is EclipseLink JPA 2.2.0 distributed with Glassfish 3.1. This is the problematic set of JPA entities : @Entity public class EventAttendance { ... @ManyToOne private Person person; @ManyToOne private Event event; ... } @Entity public class Event { ... @OneToMany(mappedBy = "event") @MapKey(name = "person") private Map<Person, EventAttendance> attendance; ... } @Entity public class Person { ... } This is a set of operation that gives erroneous results: BeginTransaction(); EntityManager em = ...; Person person = em.find(Person.class, PERSON_ID); Event event = em.find(Event.class, EVENT_ID); // This map contains at least the entry: // Key = Person with id == PERSON_ID // Value = an instance of EventAttendance Map<Person, EventAttendance> attendanceMap = event.getAttendance(); // Should return the EventAttendance instance mentioned above, but returns null! EventAttendance attendance = attendanceMap.get(person); CommitTransaction(); Digging around in the debugger, I found that the problem is that there exists 2 instances of the same Person entity in the persistence context. These 2 instances reference the same entity which violates the JPA contract. Changing the Map to a simple List gives the expected behavior whereas the Person instance with id PERSON_ID is shared between the List in Event and em.find(Person.class, PERSON_ID). Reproducible: Always
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink