Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365833 - Caching of EntityManagerFactory in PUnitInfo breaks multi-session multi-tenancy
Summary: Caching of EntityManagerFactory in PUnitInfo breaks multi-session multi-tenancy
Status: CLOSED DUPLICATE of bug 352708
Alias: None
Product: Gemini.JPA
Classification: RT
Component: Core (show other bugs)
Version: 1.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.1.0 M1   Edit
Assignee: Michael Keith CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-07 03:19 EST by Gunnar Wagenknecht CLA
Modified: 2012-07-20 11:14 EDT (History)
1 user (show)

See Also:


Attachments
project with test case and launch config (10.80 KB, application/x-zip-compressed)
2011-12-07 03:19 EST, Gunnar Wagenknecht CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2011-12-07 03:19:39 EST
Created attachment 208037 [details]
project with test case and launch config

Gemini JPA keeps a reference to a single EntityManagerFactory from the underlying PersistenceProvider in the PUnitInfo. This is used by  EMFBuilderServiceProxyHandler to return an already created EntityManagerFactory. 

Thus, if the method is called a second time with a different set of properties it returns the previously created EMF which may point to the wrong EclipseLink session. There is some verification being done in verifyJDBCProperties but that only verifies 'javax.persistence.jdbc.driver' and 'javax.persistence.jdbc.url' but not the EclipseLink session or DataSource. 

IMHO the contract of EntityManagerFactoryBuilder.createEntityManagerFactory(Map) does not state that only one EMF can be used. Thus, I think it's a valid use case to call this multiple time with different properties to create different EMFs.
Comment 1 Gunnar Wagenknecht CLA 2011-12-14 02:17:23 EST

*** This bug has been marked as a duplicate of bug 352708 ***