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

Bug 363542

Summary: [Metamodel] Moving entity to another package leads to errors
Product: [WebTools] Dali JPA Tools Reporter: Nan Li <nan.n.li>
Component: JPAAssignee: Brian Vosburgh <brian.vosburgh>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: neil.hauge
Version: unspecified   
Target Milestone: 3.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Stack Trace
none
Snapshoot none

Description Nan Li CLA 2011-11-10 17:09:19 EST
Build Identifier: I-3.1.0-20111103164637

1. Create a JPA project
2. Create a separate source folder for metamodel (This is optional, just makes things clearer.)
3. Enable metamodel
4. Generate two or more entities from tables to a package, e.g. entity.gen
5. Open one of the entity in the editor and change its package name to another one, e.g. test.gen
6. Use quick fix to move the entity updated in step 3 to the new package

There are a couple of errors at this point:

1. An error message is thrown in the error log complaining the entity updated in step 3 does not exist in the old package. Please see the attached stack traces.
2. Duplicate metamodel classes exist each of which in the old and the new package separately. Please see the attached picture.

Clean project can make the metamodel class in the old package of the updated entity go away.

Reproducible: Always
Comment 1 Nan Li CLA 2011-11-10 17:10:24 EST
Created attachment 206819 [details]
Stack Trace
Comment 2 Nan Li CLA 2011-11-10 17:10:58 EST
Created attachment 206820 [details]
Snapshoot
Comment 3 Nan Li CLA 2011-11-10 17:28:07 EST
The error message seems to be caused by AbstractPersistenceUnit.validateClassRefs because we are trying to verify the existence of the class refs listed in the persistence.xml; however, one of the classes is already moved to the new package but the persistence.xml doesn't get updated when we are moving the entity to a new package through quick fix so the persistence.xml still refers to the old class path.
Comment 4 Brian Vosburgh CLA 2012-05-10 14:47:42 EDT
These problems seem to have been fixed by the major rework of JpaProjectManager. This is probably because JPA validation now runs with a lock on the project (before, it ran unprotected). I have tested this use case and it seems to make sense that the problem should no longer occur; but you never know.... :-)

If this problem re-occurs, please re-open this bug.