Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352121 - Converting existing JPA project to Persistent Bundle does not refresh the JPA model
Summary: Converting existing JPA project to Persistent Bundle does not refresh the JPA...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Libra (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Kaloyan Raev CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-14 11:41 EDT by Kaloyan Raev CLA
Modified: 2022-02-24 11:24 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kaloyan Raev CLA 2011-07-14 11:41:06 EDT
Prerequisites:
* Install the Libra OSGi facet from the p2 repository of latest maintenance build: http://download.eclipse.org/libra/maintenance/snapshot

Steps to reproduce:
1. Create new JPA project. 
2. Right-click on the project > Configure > Convert to OSGi Bundle project. 
3. Make sure the JPA project is selected and click Finish. This wizard will install the OSGi facet. 

As a result of installing the OSGi facet, the src/META-INF folder is moved to <project-root>/META-INF. See bug 341398 for details. But the JPA model is not refreshed properly. The JPA Content node is empty and tools like the JPA Diagram Editor does not work. 

Workaround:
1. Right-click on the project > Validate. This refreshes the JPA model, but leaves an error marker on the META-INF/persistence.xml file. 
2. Repeat again: Right-click on the project > Validate. This removes the error marker. 

As part of bug 341398 I tried to refresh the JPA model in the install delegate of the OSGi facet, but could not find the proper way to do this. I've tried lots of combination using the following API, but with no luck: 

  jpaProject.update(monitor);
  jpaProject.updateAndWait();
  jpaProject.synchronizeContextModelAndWait();
  JptJpaCorePlugin.rebuildJpaProject(project);
  ValidationFramework.getDefault().validate(new IProject[] { project }, false, false, monitor);
  ValidationFramework.getDefault().validate(project.getFile(new Path(OSGiBundleFacetUtils.PERSISTENCE_URI)), monitor);

Neil, Shaun, could you give a hint here?
Comment 1 Neil Hauge CLA 2011-07-14 12:24:37 EDT
Probably the easiest workaround (from a user perspective) would be a project clean, which should resolve any stale model/validation issues.  I would think that programatically the JptJpaCorePlugin.rebuildJpaProject(project) would have done the job.  Ideally we would be listening for this type of change and would be updating the project as required, but this is obviously not in place yet.

Give rebuildJpaProject another try and try to confirm that the rebuild is taking place at the right time.