Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Two persistence units, wrong JDBC driver
Two persistence units, wrong JDBC driver [message #1690508] Fri, 27 March 2015 16:38 Go to next message
Bernd Prager is currently offline Bernd PragerFriend
Messages: 6
Registered: November 2012
Junior Member
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 #1690509 is a reply to message #1690508] Fri, 27 March 2015 17:00 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Bernd,

Are you sure your two persistence units have different names? In your logs, do you see the Oracle-based one processed by EclipseLink?

-Mike
Re: Two persistence units, wrong JDBC driver [message #1690518 is a reply to message #1690509] Fri, 27 March 2015 19:46 Go to previous messageGo to next message
Bernd Prager is currently offline Bernd PragerFriend
Messages: 6
Registered: November 2012
Junior Member
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 21:31 Go to previous message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
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
Previous Topic:Apache tomcat catalina springsource bundle is not RESOLVED on equinox OSGi container
Next Topic:Gemini Web 2.2.7 RELEASE is now available
Goto Forum:
  


Current Time: Fri Apr 19 06:32:05 GMT 2024

Powered by FUDForum. Page generated in 0.02196 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top