Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 365833

Summary: Caching of EntityManagerFactory in PUnitInfo breaks multi-session multi-tenancy
Product: [RT] Gemini.JPA Reporter: Gunnar Wagenknecht <gunnar>
Component: CoreAssignee: Michael Keith <michael.keith>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: shaun.smith
Version: 1.0.0   
Target Milestone: 1.1.0 M1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
project with test case and launch config none

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 ***