Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Initialize EclipseLink at runtime
Initialize EclipseLink at runtime [message #523076] Wed, 24 March 2010 19:10 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
Registered: July 2009
Senior Member
Hi,
My question is if it is possible to initialize EclipseLink at runtime without making use of hardcopy files (like
persistence.xml or orm.xml). Can the mapping be supplied as an inputstream for example?

--

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@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Initialize EclipseLink at runtime [message #523105 is a reply to message #523076] Thu, 25 March 2010 06:36 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
On 2010-03-25 0:38, Martin Taal wrote:
> Hi,
> My question is if it is possible to initialize EclipseLink at runtime
> without making use of hardcopy files (like persistence.xml or orm.xml).
> Can the mapping be supplied as an inputstream for example?
>

AFAIK Eclipselink can completely be configured using Java code. However, I'm not sure if the JPA standard requires the persistence.xml to be present (so that would be a definition issue).
Re: Initialize EclipseLink at runtime [message #523268 is a reply to message #523076] Thu, 25 March 2010 17:39 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Using the JPA Persistence class, you need to have a persistence.xml.

You could call the EclipseLink PersistenceProvider class directly, or create the EclipseLink EntityManagerFactoryImpl directly.

You would still need some way to define your persistence info and mappings. You could create your EclipseLink ServerSession and ClassDescriptor and DatabaseMappings directly through code, or use the MetadataProcessor to parse your annotations if you have that.

Why can't you have a file? Where is your mapping info coming from?


James : Wiki : Book : Blog : Twitter
Re: Initialize EclipseLink at runtime [message #523469 is a reply to message #523268] Fri, 26 March 2010 14:01 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
Registered: July 2009
Senior Member
Thanks, I am generating the orm mapping at runtime therefore it is far more handier to not have it in a file somewhere.

The easiest would be if there is an api which just gets an inputstream or string which I can use. Does such an api exist
(this is what the MetaDataProcessor can do, correct?)?
Btw, I could not find the MetadataProcessor class (I am using Helios), where is it located?

I still would need a persistence.xml file somewhere? Or is there a way to also do that part programmatically?

gr. Martin

James wrote:
> Using the JPA Persistence class, you need to have a persistence.xml.
>
> You could call the EclipseLink PersistenceProvider class directly, or
> create the EclipseLink EntityManagerFactoryImpl directly.
>
> You would still need some way to define your persistence info and
> mappings. You could create your EclipseLink ServerSession and
> ClassDescriptor and DatabaseMappings directly through code, or use the
> MetadataProcessor to parse your annotations if you have that.
>
> Why can't you have a file? Where is your mapping info coming from?


--

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@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Initialize EclipseLink at runtime [message #523914 is a reply to message #523076] Mon, 29 March 2010 19:32 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

It might be easier to build the RelationalDescriptor and DatabaseMappings directly, instead of generating an orm.xml file then parsing it.

MetadataProcessor is in,
org.eclipse.persistence.internal.jpa.metadata


James : Wiki : Book : Blog : Twitter
Previous Topic:Bug in NOT MEMBER OF translation?
Next Topic:audit tracking
Goto Forum:
  


Current Time: Sun Dec 21 17:32:58 GMT 2014

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

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