Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348143

Summary: NullPointerException: Add entity to XML
Product: [WebTools] Dali JPA Tools Reporter: Nan Li <nan.n.li>
Component: GeneralAssignee: Karen Butzke <karenfbutzke>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jolene.moffitt, neil.hauge
Version: unspecifiedFlags: neil.hauge: review+
Target Milestone: 3.0.1   
Hardware: PC   
OS: Windows 7   
Whiteboard: fix_ready
Attachments:
Description Flags
proposed patch against head none

Description Nan Li CLA 2011-06-02 17:15:13 EDT
Build Identifier: I20110525-0800

1. Create a brand new JPA project with a mapping xml created along with it (selecting "Create mapping file (orm.xml) checkbox" when creating the JPA project)
2. Right-click the created JPA project and select New -> JPA Entity to create an entity, select "Add to entity mappings in XML" checkbox when it shows, create a couple of fields for the entity, and hit Finish.

An error is reported saying 

An internal error occurred during: "Add entity to XML".
java.lang.NullPointerException
	at org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.operation.NewEntityClassOperation$1.run(NewEntityClassOperation.java:411)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

And you can also see the fields created for the entity in step 2 are not written to the mapping XML at all.

Reproducible: Always
Comment 1 Karen Butzke CLA 2011-06-09 09:57:16 EDT
The key to reproducing this bug is that you have to make one of the fields an id field.
Comment 2 Karen Butzke CLA 2011-06-10 08:33:58 EDT
Created attachment 197767 [details]
proposed patch against head

This patch changes the JPA project synchronizers to be synchronous when editing the orm.xml file. This allows the model to be fully updated when one change is made before another change is made. This is necessary when changing the model in code.
Comment 3 Karen Butzke CLA 2011-06-24 08:04:58 EDT
checked in to HEAD for 3.0.1
Comment 4 Jolene Moffitt CLA 2011-08-03 13:13:11 EDT
Verified in Build I-3.4.0-20110731180834

Verified you can create an entity with an id attribute and add it to the orm.xml mapping file without error.  See the link to view test steps for
verification. http://wiki.eclipse.org/Dali_3.0.1