Hi all, I'm new to JPA/OpenJPA. I have managed to get OpenJPA to use my connection pool for connections. My next step is to make something handy for getting EntityManager instances. I am writing web applications (Tomcat). What I do with connections is initialize my connection pool at web app startup and close the pool at web app shut it down. Each request to the web application gets its own connection which is guaranteed to be closed/freed at the end of the request. I'm looking for details about how this pattern might match JPA. Is EntityManagerFactory analogous to the connection pool in that I should create it upon web app startup and close it at web app shut down? Is EntityManager analogous to connection in that each request should acquire its own EM and then close it at the end of the request?
I have read in the docs about the handling of concurrency. It seems the EM can detect when 2 objects representing the same row in the database are attempting a concurrent update (load A and B instances of same row, change A and B, update A, cool, update B, error). Is this handled within a single EM instance? If so, it seems an EM needs to be a single instance across all users, but it appears only one transaction at a time is allowed, so that can't be right. Any help clearing this up is appreciated. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:[email protected]
