Can I use EclipseLink without sessions.xml/project.xml [message #1157650] |
Sun, 27 October 2013 07:02  |
Eclipse User |
|
|
|
Hi,
I am upgrading the test environment of the EMF Texo project to use the latest EclipseLink project. For this test
environment I generate persistence.xml file for each separate test model (there are around 50). So each testmodel will
have a persistence.xml called for example: accounting-persistence.xml
Until now I initialized Eclipselink like this:
properties.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "META-INF/" //$NON-NLS-1$
+ getPersistenceXMLPrefix() + "-persistence.xml"); //$NON-NLS-1$
so that it made use of the correct persistence.xml when testing.
This doesn't work, it fails for example here:
Session session = SessionManager.getManager().getSession(getPersistenceUnitName());
as it can't find the accounting persistence unit, it seems that the accounting-persistence.xml is not being read.
Is there a way that I can accomplish this? Should I generate a sessions.xml file for each test model and more
importantly if so how can I tell EclipseLink to use that specific acccounting-sessions.xml (and a different one for each
testmodel)? And also which persistence.xml it will use.
Thanks for any insights in this!
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: Can I use EclipseLink without sessions.xml/project.xml [message #1163782 is a reply to message #1159346] |
Thu, 31 October 2013 03:56   |
Eclipse User |
|
|
|
Thanks, I am running in an OSGI environment, is there a way that I can use Gemini JPA without sessions.xml?
gr. Martin
On 10/28/2013 02:11 PM, Chris Delahunt wrote:
> SessionManager.getManager().getSession(name) is used for loading EclipseLink sessions from Sessions.xml, while
> persistence.xml is loaded using JPA's Persistence.getEntityManagerFactory("classpath:default") to get an
> EntityManagerFactory. If you are going to use a persistence.xml, you can always get the EclipseLink native Session
> instance from the EntityManager using em.unwrap(JpaEntityManager.class).getServerSession(), allowing you to use the JPA
> and access native EclipseLink api as needed.
>
> Best Regards,
> Chris
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
Powered by
FUDForum. Page generated in 0.03986 seconds