Bug 391062 - AggregateCollectionMapping Map on Embedded causes NPE during pu deploy
Summary: AggregateCollectionMapping Map on Embedded causes NPE during pu deploy
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-03 15:18 EDT by Andrei Ilitchev CLA
Modified: 2022-06-09 10:09 EDT (History)
2 users (show)

See Also:


Attachments
Suggested patch (5.35 KB, patch)
2012-10-03 15:28 EDT, Andrei Ilitchev CLA
no flags Details | Diff
Testcase (5.28 KB, application/x-zip-compressed)
2016-08-23 02:35 EDT, Christian Beikov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Ilitchev CLA 2012-10-03 15:18:19 EDT
@Entity
@Table(name="TLG_CONTACT")
public class Contact implements Serializable, PortableObject {
    @Id
    protected String info;
...    
    @Embedded
    protected InternalItemsHolder internalItemsHolder;
...
}

@Embeddable
public class InternalItemsHolder implements Serializable, PortableObject{
...
    @ElementCollection()
    @CollectionTable(name= "TLG_INTERN_HOLDER_ACTION_ITEMS")
    @MapKeyColumn(name="KEY")
    protected Map<Integer, ActionItem> actionItems;*/
...
}

@Embeddable
public class ActionItem implements Serializable, PortableObject{    
    protected String description;
...}

causes NPE during persistence unit deployment (descriptor initialization).

Note that even after this bug is fixed usage of AggregateCollectionMappings Maps on Embedded would still be impossible due to bug 391060.
Comment 1 Andrei Ilitchev CLA 2012-10-03 15:28:36 EDT
Created attachment 221864 [details]
Suggested patch

MappedKeyContainer policy holds a back reference to the mapping - valueMapping.
The problem is that this attribute is not reset after the mapping is cloned: the cloned container policy still holds reference to the original mapping.

To fix this CollectionPolicy should use setContainerPolicy method in clone (not just assign the cloned container policy) and setContainerPolicy should be overridden by all implementor of MapComponentMapping interface to set correct valueMapping.
Comment 2 Tom Ware CLA 2013-04-03 11:35:07 EDT
see also: 391060
Comment 3 Christian Beikov CLA 2016-08-23 02:35:20 EDT
Created attachment 263710 [details]
Testcase

Can anyone confirm that this is the same bug? I attached a testcase that fails with a NPE with a ManyToMany mapping of a map in an embeddable.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:09:37 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink