The difference between Appfuse 1.9.x from Appfuse 2.x in Hibernate DAO programming is annotation method. In Appfuse 2.x, we can use JPA annotation to do the OR mapping. The major benefit of Java annotation is the compile time syntax correction.
The JPA annotation is pretty straightforward, I suggest you to read this article if you just like me as a rookie of this.
Be aware the imported class of the annotation. I make this mistake, and the result is the entity table was not appear when executing mvn test-compile hibernate3:hbm2ddl
You may wondering that should we tell the hibernate where to find the annotated class to interpreter. The answer is yes, you need to add a line of xml in hibernate.cfg.xml in the src/main/resources/hibernate.cfg.xml file.
I add the following xml to my hibernate.cfg.xml.
"
Reference:
- http://www.onjava.com/pub/a/onjava/2007/02/08/an-introduction-to-hibernate-3-annotations.html
- http://appfuse.org/display/APF/Persistence#Persistence-createschema
沒有留言:
張貼留言