This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Jack Rooney
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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):

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...


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!