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?
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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With