• 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

How does JPA manage sessions / connections?

 
Ranch Hand
Posts: 115
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I'm trying to understand when my code will actually make a connection to the database. Are the following true?
1) Calling em.getTransaction().commit() or em.close() will connect to the database.
2) Calling em.close() will disconnect from the database.

If I have a web application, and I have only created one EntityManager at start of the application to be used by all users from different locations, and each of these users can make calls to the database, would the EntityManager line up all the requests in series or initiate multiple connections to the database for each of the requests?

From the following posts it appears mixing multi-thread with a JPA provider can be nasty. So would the same thing happen to a web based application?
http://blog.xebia.com/2009/02/07/hibernate-and-multi-threading/
reply
    Bookmark Topic Watch Topic
  • New Topic