aspose file tools*
The moose likes Object Relational Mapping and the fly likes Best way to setup / configure Tomcat 7 web app with Hibernate 3 / JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Best way to setup / configure Tomcat 7 web app with Hibernate 3 / JPA" Watch "Best way to setup / configure Tomcat 7 web app with Hibernate 3 / JPA" New topic
Author

Best way to setup / configure Tomcat 7 web app with Hibernate 3 / JPA

Jack Rooney
Greenhorn

Joined: Dec 04, 2012
Posts: 14
Hello,

I am using JDK 1.6, Maven 2.2.1, Tomcat 7, Eclipse Juno (Enterprise Edition), Hibernate 3 /JPA, and MySQL 5.

Am relatively new to Hibernate / JPA. What I am seeking to do is have my tomcat 7
connect to the database as soon as my webapp is loaded by tomcat 7's classloader (during server startup).

hibernate.cfg.xml (Located in myapp/src/main/resources):



HibernateUtil.java:



I created this class do use my HibernateUtil during server startup:



Registerd it with my web.xml:



So, far everything seem to look like its works... However, on the Internet after googling it,
I saw that people are using EntityManagerFactory... What's the difference between the two?

What's the standard way to setup a Tomcat based web app using Hibernate / JPA against a MySQL database?

What I am seeking to do is being able to save my POJOs (after setting them) and then issuing something like



without having to constantly open and close connections to my database.

Thanks for all your help...

Regards,

Jack
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best way to setup / configure Tomcat 7 web app with Hibernate 3 / JPA