• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic