How can I generate JPA2 compliant @Entity from existing Databases?.
I found this: Question
Still its not clear if JBoss will generate compliant JPA2 and also
Try using OPENJPA Reverse mapping tools. They offer lot more facility and are easy to configure. This example would clarify.
If you are using maven as your build tool, add this entry to your pom.xml
org.codehaus.mojo
exec-maven-plugin
1.2
org.apache.openjpa.jdbc.meta.ReverseMappingTool
-directory src/main/java -accessType fields
-useGenericCollections true -package org.yourproject.model
-metadata none -annotations true
-innerIdentityClasses false -useBuiltinIdentityClass false
-primaryKeyOnJoin false
true
javax.validation
validation-api
1.0.CR3
org.apache.openjpa
openjpa-all
2.0.1
Also add following properties in the persistence.xml which lies in your META-INF folder of your resources. These would be harnessed by openjpa tool to establish connection to the database.
To generate the Entity files simply launch the maven goal in the project directory using mvn org.codehaus.mojo:exec-maven-plugin:java and it will generate the files at the desired location.