Permalink
Browse files

furthur document the JPA metamodel generation

don't start with a compile dependency on the metamodel (to avoid confusion)
introduce out-of-box Eclipse settings to generate JPA metamodel
  • Loading branch information...
1 parent ca64a01 commit 1f03eba8624145eb43fa977d556bed20207debd9 @mojavelinux mojavelinux committed Jul 17, 2010
View
@@ -15,14 +15,16 @@ ARCHETYPE_RESOURCES_DIR=$ARCHETYPE_DIR/src/main/resources/archetype-resources
echo Generating archetype from project into $ARCHETYPE_BUILD_DIR...
mvn clean archetype:create-from-project -Darchetype.properties=archetype.properties
echo Relocating generated archetype project to $ARCHETYPE_DIR...
-rsync -az --exclude `basename $0` --exclude archetype-pom.xml $ARCHETYPE_BUILD_DIR/src $ARCHETYPE_DIR/
+rsync -az --exclude `basename $0` --exclude archetype-pom.xml --exclude eclipse-dot-files $ARCHETYPE_BUILD_DIR/src $ARCHETYPE_DIR/
+rsync -az eclipse-dot-files/ $ARCHETYPE_RESOURCES_DIR/
cp -f archetype-pom.xml $ARCHETYPE_DIR/pom.xml
mvn -f $ARCHETYPE_DIR/pom.xml clean
echo Patching generated archetype...
# could also use col -b
sed -i 's;;;' $ARCHETYPE_RESOURCES_DIR/pom.xml
sed -i 's;;;' $ARCHETYPE_RESOURCES_DIR/readme.txt
sed -i 's;<name>jboss-javaee6-webapp-src</name>;<name>${name}</name>;' $ARCHETYPE_RESOURCES_DIR/pom.xml
+sed -i 's;eclipse-dot-files/\?;;' $ARCHETYPE_DIR/src/main/resources/META-INF/maven/archetype-metadata.xml
# remove local file that NetBeans add to source project
rm -f $ARCHETYPE_RESOURCES_DIR/src/main/webapp/WEB-INF/sun-web.xml
# could set the release version at this point, if specified
@@ -0,0 +1,5 @@
+<factorypath>
+ <factorypathentry kind="PLUGIN" id="org.eclipse.jst.ws.annotations.core" enabled="true" runInBatchMode="false"/>
+ <factorypathentry kind="VARJAR" id="M2_REPO/org/hibernate/hibernate-jpamodelgen/1.0.0.Final/hibernate-jpamodelgen-1.0.0.Final.jar" enabled="true" runInBatchMode="false"/>
+ <factorypathentry kind="VARJAR" id="M2_REPO/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.0.Final/hibernate-jpa-2.0-api-1.0.0.Final.jar" enabled="true" runInBatchMode="false"/>
+</factorypath>
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=false
+org.eclipse.jdt.apt.genSrcDir=target/generated-sources/annotations
+org.eclipse.jdt.apt.reconcileEnabled=true
View
@@ -19,7 +19,7 @@
All you need to run this project is Java 5.0 (Java SDK 1.5) or greator and
Maven 2.0.10 or greater. This application is setup to be run on a Java EE 6
- application server. We've tested it on GlassFish 3 and JBoss AS 6.0.
+ application server. We've tested it on GlassFish 3.0.1 and JBoss AS 6.0.0.M3.
Please note that Maven 2 project needs to use the JBoss Nexus Maven repository
because there are certain Java EE API JARs that are not yet publised to the
@@ -66,21 +66,21 @@
mvn package jboss:hard-deploy
This will deploy two artifacts, target/jboss-javaee6-webapp-src.war and
- default-ds.xml. The latter installs a data source named jdbc/__default,
- so both JBoss AS and GlassFish have a data source with the same name.
+ default-ds.xml.
+
+ NOTE:
+ If you deploy the WAR manually, don't forget to also deploy default-ds.xml!
+ The default-ds.xml file installs a data source named jdbc/__default, so both
+ JBoss AS and GlassFish have a data source with the same name.
You can also set jboss.home on the commandline:
mvn package jboss:hard-deploy -Djboss.home=/path/to/jboss-as-6.0.0.M3
Start JBoss AS. The application will be running at the following URL:
- http://localhost:8080/jboss-javaee6-webapp-src/home.jsf
+ http://localhost:8080/jboss-javaee6-webapp-src/
- Note: If you are using JBoss AS 6.0.0.M3, you may encounter the exception
- described in https://jira.jboss.org/browse/WELD-448 if you attempt to access
- to root context path (i.e., /).
-
To undeploy from JBoss AS, run this command:
mvn jboss:hard-undeploy
@@ -153,14 +153,21 @@
Select File > Import... and select "Existing Maven Projects" and navigate to
your project directory. Click Finish and m2eclipse will take it from there.
- Once in the IDE, you can execute the Maven commands through the IDE controls
- to deploy the application to a container.
+ Additional configuration is required to get Eclipse to generate the JPA
+ metamodel. The archetype includes the necessary Eclipse config files in your project.
+ To enable this feature, right click on the project and select:
- NOTE: If the project shows a compile error after import, it's likely that the
- generated sources are not on the Eclipse project classpath. Right click the
- project and select:
+ Properties > Java Compiler > Annotation Processing
- Maven > Update Project Configuration
+ Check "Enable annotation processing" then click OK and OK again when your are
+ prompted to run a project build.
+
+ You can verify your configuration by referring to the Hibernate JPA documentation.
+
+ http://docs.jboss.org/hibernate/stable/jpamodelgen/reference/en-US/html_single/#d0e319
+
+ Once the project is imported into the IDE, you can execute the Maven commands
+ through the IDE controls to deploy the application to a container.
Downloading the sources and Javadocs
====================================
@@ -40,8 +40,9 @@ public void fetch()
{
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Member> criteria = cb.createQuery(Member.class);
- Root<Member> widget = criteria.from(Member.class);
- criteria.select(widget).orderBy(cb.asc(widget.get(Member_.name)));
+ Root<Member> member = criteria.from(Member.class);
+ // replace "name" with Member_.name if the JPA metamodel has been generated
+ criteria.select(member).orderBy(cb.asc(member.get("name")));
members = em.createQuery(criteria).getResultList();
}
}

0 comments on commit 1f03eba

Please sign in to comment.