This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 258235 - NB fails to rebuild static metamodel if org.eclipse.persistence is removed from pom.xml
Summary: NB fails to rebuild static metamodel if org.eclipse.persistence is removed fr...
Status: NEW
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 8.1
Hardware: PC Windows 10 x64
: P3 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-04 02:01 UTC by omniprof
Modified: 2016-03-04 03:29 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description omniprof 2016-03-04 02:01:02 UTC
I have discovered the following:

A Maven project is first created with org.eclipse.persistence dependencies so that the static metamodels are created. The dependencies are added when the persistence.xml file is created.

Clean and build and the generated sources appear with the static metadata for the entities.

Remove the org.eclipse.persistence dependencies from the pom.xml 

Clean and build and the generated resources are removed.

This is the expected behaviour.

Restore the org.eclipse.persistence dependencies to the pom.xml

Clean and build and the generated sources do not appear.

I discoveded that the only way to restore the generated static metamodel is to edit the persistence.xml file in some minor way so that it is saved.

Clean and build and the generated sources reappear.

Should not NetBeans check for generated sources on every clean and build regardless of whether the persistence.xml, I suspect, has a newer timestamp from a fresh save? Or is this possibly a Maven issue?

As a teacher I frequently change code as part of a lecture and had I not spotted this annomaly tonight I would have looked foolish in tomorrow's class. As it stands I will look a bit silly as I explain that you must kick (save it without changes) the persistence.xml file to regenerate static metadata.
Comment 1 omniprof 2016-03-04 03:02:21 UTC
Further testing has revealed that sometimes kicking the file works and sometimes it does not. Even more confuing is that I have one sample program that never fails to generate the metamodels while another will no longer generate. I will use two different projects in class rather than modify an exiting project.
Comment 2 omniprof 2016-03-04 03:29:02 UTC
Final comment, if I open the persitence.xml and change the "Include all Entity Classes" check box, save the file, go back and restire the check to its original state, save the file and do a build rather than clean and build now the generated souces will appear. This appears to be consistent.

You can seee the project at 
https://gitlab.com/omniprof/JPAQueryWorld.git

The SQL script for the MySQL world db is found in Other Test Sources. The servlet contains multiple types of queries but only the first is uncommented and is what I plan to use to demonstrate the static metamodel.