views:

233

answers:

4

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?

+2  A: 

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

Pascal Thivent
Hi, thanks for your answer. I'll check again in Netbeans and try to add the eclipselink model generation jar.
dariopy
I don't get this to work in Netbeans 6.9.1 in my maven nb platform. I've even tried the sample code here, but it also didn't recohttp://agoncal.wordpress.com/2010/05/28/jpa-2-0-criteria-api-with-maven-and-eclipselink/
simpatico
A: 

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

mkleint
A: 

Milos is correct - use the latest Maven compiler plugin, and also the latest EclipseLink. Plus, the eclipselink-jpa-modelgen.jar file must be in your dependencies.

The easiest way to set up the project is to download the latest nightly build of NetBeans 6.10 from http://bits.netbeans.org/netbeans/trunk/nightly/ and create the project in this build - everything should work well. Then you can continue editing this project in NetBeans 6.9.1.

Petr J
A: 

Petr J. Newbie trying to set up Criteria API with Netbeans JPA Eclipselink as a web app utilizing maven. Per your August 12 comment, can you reference where I can go to find what settings I need to change in Netbeans 6.10 to move from not creating metamodel to creating metamodel

mlb