How to share EntityManagerFactory when different MetaDataSource per tanant [message #810683] |
Thu, 01 March 2012 12:22 |
pin xia Messages: 1 Registered: March 2012 |
Junior Member |
|
|
I am using eclipselink 2.3.2 and trying its multi-tenancy and extensible entity features.
I defined an entity class A (Ignored other annotations and attributes)
@Multitenant(SINGLE_TABLE)
@VirtualAccessMethods
@TenantDiscriminatorColumn(name = "TENANT_ID", length = 12, contextProperty = "t.id")
@Entity
public class A{
@Transient
protected Map<String, Object> extensions = new FastMap<String, Object>();
@SuppressWarnings("unchecked")
public <T> T get(String name){
return (T) extensions.get(name);
}
public Object set(String name, Object value){
return extensions.put(name, value);
}
}
I also defined a class MyMetadataSource which implements MetadataSource.
MyMetadataSource class gets different extension metadata for different tenant.
There are two lines in persistence.xml
<property name="eclipselink.multitenant.tenants-share-emf" value="false" />
<property name="eclipselink.metadata-source" value="MyMetadataSource" />
Eveything works well as my expected. different EMF can be created for different tenant.
But the problem is one EMF per tenant is two heavy, I want to share the "public" metadata which is annotated in class A. The "private" metadata will be got at rumtime for different tenant. Is it possible?
I found there is a description from MySports example
http___://wiki.eclipse.org/EclipseLink/Examples/MySports
to describle this, but I am not quite understand it, anyone can give me the help?
When developing an application that can handle requests from multiple tenants you can choose to have a single EntityManager Factory (EMF) with tenant scoped EntityManagers (EM) or you can choose to have a EMF per tenant.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03116 seconds