Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Can I use EclipseLink without sessions.xml/project.xml
Can I use EclipseLink without sessions.xml/project.xml [message #1157650] Sun, 27 October 2013 11:02 Go to next message
Martin Taal is currently offline Martin Taal
Messages: 5339
Registered: July 2009
Senior Member
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 #1159346 is a reply to message #1157650] Mon, 28 October 2013 13:11 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
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
Re: Can I use EclipseLink without sessions.xml/project.xml [message #1163782 is a reply to message #1159346] Thu, 31 October 2013 07:56 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5339
Registered: July 2009
Senior Member
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
Re: Can I use EclipseLink without sessions.xml/project.xml [message #1164152 is a reply to message #1163782] Thu, 31 October 2013 13:17 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
I would assume the Gemini JPA project is based off the JPA spec which requires a persistence.xml.
Previous Topic:Issues with uow.getOriginalVersionOfObject(workingClone)
Next Topic:How to configure eclipselink.connection-pool.sequence
Goto Forum:
  


Current Time: Sun Oct 26 08:41:03 GMT 2014

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

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