Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA 2.0 metamodel in Netbeans?

I've read that since version 6.9, Netbeans includes annotation processing support, a feature needed, for instance, to generate JPA 2.0 entities' metamodels.

However, I couldn't find any examples or documentation that shows exactly how to do it. Have any of you guys succeed on this?

like image 573
dariopy Avatar asked Jul 28 '10 21:07

dariopy


2 Answers

I didn't experiment this feature in NetBeans 6.9 but according to the release notes (and to Bug 178108), my understanding is that this is supposed to work out of the box if you are using EclipseLink (and if you add eclipselink-jpa-modelgen.jar to the classpath):

Java Persistence

Creation of new persistence unit was simplified in all wizard, in Entity From Database wizard the most suitable persistence unit will be created by default.

Now metamodel classes will be generated for project entities if persistence unit will be created with eclipselink provider (supported in j2se, web, ejb and application client projects). Automatic processor addition is temporary disabled because of an issue in eclipselink, you can add eclipselink-jpa-modelgen jar from eclipselink distribution to your project manually to enable metamodel generation.

The entity from DB wizard was enhanced to allow regeneration. It allows user to regenerate the entity from scratch after structural DB change or update the entity class by adding the code for the new DB fields.

For other persistence providers, did you actually try to add their metamodel generator JAR and to declare the annotation processor as suggested in part I and part II of the link you provided?

Related question

  • How to generate JPA 2.0 metamodel?
like image 110
Pascal Thivent Avatar answered Oct 12 '22 16:10

Pascal Thivent


maven compiler plugin has problems with annotation processors. it's not straightforward to do with maven ans sometimes it fails. Applies not only to the JPA but also to netbeans' own annotations and processors that generate code. Even if not hit by any of the issues you might need to configure the compiler plugin to work with ann processors.. make sure to use the latest and greatest of m-c-p, some issues were fixed there.

http://jira.codehaus.org/browse/MCOMPILER-122 http://jira.codehaus.org/browse/MCOMPILER-97 http://jira.codehaus.org/browse/MCOMPILER-71 http://jira.codehaus.org/browse/MCOMPILER-66

like image 41
mkleint Avatar answered Oct 12 '22 17:10

mkleint