|
Re: Changing schema of ClassDescriptor in Container [message #1082389 is a reply to message #1081718] |
Thu, 08 August 2013 14:02 |
|
All EntityManagers from the same EntityManagerFactory will share the same tableQualifier and descriptors, so this is not a good idea.
You should create a new EntityManagerFactory per schema. Unfortunately there is currently no persistence unit property for setting the schema (please log a bug for this), so you will need to set the tableQualifier using a SessionCustomizer. Normally multiple EntityManagerFactorys for the same persistence unit will share the same Session, so you will also need to set the persistence unit property "eclipselink.session-name" to be unique for each schema.
Another option is to have a different user for each schema that defaults to that schema, then just acquire the EntityManagerFactory with the different user.
You may also want to look into EclipseLink's multi tenant support,
http://www.eclipse.org/eclipselink/documentation/2.5/solutions/multitenancy003.htm#A1235913
James : Wiki : Book : Blog : Twitter
|
|
|
Re: Changing schema of ClassDescriptor in Container [message #1085281 is a reply to message #1082389] |
Mon, 12 August 2013 17:55 |
Missing name Mising name Messages: 16 Registered: September 2011 |
Junior Member |
|
|
First, thanks for the help.
But, I have some "severe" requirements, which are getting really ugly to handle in Eclipselink that should be relatively simple, I am just having loads of fun finding the "right" way to do this.
First, I am in a container using Stateless EJBs where the PersistenceContext/Unit is injected. I have to maintain transaction consistency with the container. Second, the schema (table qualifier) is not set on all entities, and I have to be able to set it "uniquely" for each user accessing the application.
What I tried to do with your code, is to set a ThreadLocal with the schema ID in the servlet, then connect to the Session bean and see the SchemaCustomizer fire and let me set the schema for THAT session. But as far as I can tell, the customizer is only firing once for eclipselink logging into the database. It never fires again until I reload the application! I am looking into the "Dynamic" classes, but I am limited to JPA1 in this container (WebLogic 10.3) so I have to be very careful that I don't grab JPA2 capabilities.
If anyone can provide some help, again, GREATLY APPRECIATED.
Thanks
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04531 seconds