• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic