Two persistence units, wrong JDBC driver [message #1690508] |
Fri, 27 March 2015 12:38  |
Eclipse User |
|
|
|
I implemented two different persistence units. One is using an Oracle the other a Microsoft JDBC driver.
Unfortunately in both connections the MS driver is selected, so I can't find any entities from the Oracle database.
The persistence.xml in my bundle clearly requires the Oracle driver:
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" />
Any native JPA Query would give me an MS SQL error:
[EL Warning]: 2015-03-27 11:35:10.996--UnitOfWork(1669701507)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'dual'.
Error Code: 208
Call: SELECT 1 FROM dual
Query: DataReadQuery(sql="SELECT 1 FROM dual")
gogo: PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'dual'.
Error Code: 208
Why is the driver property being ignored? Has anybody successfully done this? Any idea how I can chase that down?
I am using gemini jpa 1.2.0.M1.
Thank you for any help!
|
|
|
|
Re: Two persistence units, wrong JDBC driver [message #1690518 is a reply to message #1690509] |
Fri, 27 March 2015 15:46   |
Eclipse User |
|
|
|
Yes, I have two different deployed persistence units in my log:
[EL Finest]: jpa: 2015-03-27 15:34:18.821--ServerSession(622033744)--Thread(Thread[Gogo shell,5,main])--End predeploying Persistence Unit projects; session /projects; state Predeployed; factoryCount 0
...
[EL Finest]: jpa: 2015-03-27 15:34:21.543--ServerSession(1161000327)--Thread(Thread[Gogo shell,5,main])--End predeploying Persistence Unit assignments; session /assignments; state Predeployed; factoryCount 0
On further investigation, I was looking at all the properties within the referenced EntityManagerFactory. The one which is supposed to contain all the Oracle JDBC properties is still getting all the MS JDBC properties.
So the reference to the emf does not seem to work properly.
This is how I reference:
private static final String PERSISTENCE_UNIT_NAME = "assignments";
@Reference(target = ("osgi.unit.name=" + PERSISTENCE_UNIT_NAME))
private EntityManagerFactory emf;
In this case I am still getting the emf for the MS persistence unit "projects" instead of the Oracle "assignments".
According to the documentation on multitenancy, I should not need to create multiple EMFs on my own, since each provider bundle contains its own persistence unit, correct?
|
|
|
Re: Two persistence units, wrong JDBC driver [message #1690521 is a reply to message #1690518] |
Fri, 27 March 2015 17:31  |
Eclipse User |
|
|
|
Try printing out the properties returned by EntityManagerFactory.getProperties() and see what you have. that will tell you whether you ahve the wrong EMF or whether you ahve a config problem.
If it turns out that the wrong one is getting injected it might be that the Oracle one is not available. Gemini JPA will not register the EMF if it can't load the driver, so make sure the driver is on the bundle classpath, etc.
-Mike
|
|
|
Powered by
FUDForum. Page generated in 0.03204 seconds