Home » Modeling » EMF » [Teneo] Having multiple orm.xml
[Teneo] Having multiple orm.xml [message #557097] |
Sat, 04 September 2010 09:55 |
|
Hi,
I am using OSGi + EMF + Teneo + Eclipselink. I will be creating multiple EMF model plugins, each of which will generate an EMF model bundle with the generated entities. Each model will be saved to its own Resource. Teneo will be used to generate the orm.xml. I have created a service bundle named ResourceLocator that contains the code that does the EMF <==> Eclispelink stuff.
public Resource locate(final EClass contentType, final EAttribute feature, final String value, final String persistenceUnitName) {
// create EclipseLink URI for saving/loading library model in/from database
final String query = EclipseLinkURIUtil.createContentsEqualQuery(contentType, feature, value);
final URI uri = EclipseLinkURIUtil.createEclipseLinkURI(persistenceUnitName, query);
// save library model instance in database
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("eclipselink", new EclipseLinkResourceFactoryImpl());
resourceSet.getLoadOptions().putAll(getTestPersistenceUnitProperties());
final Resource resource = resourceSet.getResource(uri, true);
return resource;
}
Now I have the question: Where do I put all of the orm.xml files? Seems I have a few options:
- leave them in the model bundles and add imports to all of them
- move them to the service bundle, rename them and reference them in persistence.xml
- try to achieve this with bundle fragments
I do not like the first, because in principle the service should not have to know anything about its clients. I dislike the second a bit less, but essentially it has the same design flaw. The third would be the least intrusive as the coupling is done at runtime by the client, but I am not certain if it will fly.
Any thoughts or advice on this? This has to be a common scenario with EMF <==> Eclipselink mapping for anything but the most trivial model, but I have not seen any discussions around it.
Many thanks,
Joel
[Updated on: Sat, 04 September 2010 09:59] Report message to a moderator
|
|
|
Re: [Teneo] Having multiple orm.xml [message #557147 is a reply to message #557097] |
Sun, 05 September 2010 11:36 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Joel,
I have the orm.xml in the model plugins. I don't see another way then letting your service layer have access to the
orm.xml as it needs to know how to persist the entities. Maybe the eclipselink newsgrooup can provide some more insights.
Btw, it can be an idea to check out the Texo project which has a better orm.xml/eclipselink support than Teneo. It
depends on your usage scenario, Texo is not for rcp environments more for server side web apps. But it can be of interest:
http://wiki.eclipse.org/Texo
http://wiki.eclipse.org/Texo#ORM.2FJPA_generation_topics
gr. Martin
On 09/04/2010 11:55 AM, Joel Rosi-Schwartz wrote:
> Hi,
>
> I have a slightly different slant on this question, but as it is in the
> same vain I think it is useful if I continue this thread.
>
> I am using OSGi + EMF + Teneo + Eclipselink. I will be creating multiple
> EMF model plugins, each of which will generate an EMF model bundle with
> the generated entities. Each model will be saved to its own Resource.
> Teneo will be used to generate the orm.xml. I have created a service
> bundle named ResourceLocator that contains the code that does the EMF
> <==> Eclispelink stuff.
>
> public Resource locate(final EClass contentType, final EAttribute
> feature, final String value, final String persistenceUnitName) {
> // create EclipseLink URI for saving/loading library model in/from database
> final String query =
> EclipseLinkURIUtil.createContentsEqualQuery(contentType, feature, value);
> final URI uri =
> EclipseLinkURIUtil.createEclipseLinkURI(persistenceUnitName, query);
>
> // save library model instance in database
> final ResourceSet resourceSet = new ResourceSetImpl();
>
> resourceSet.getResourceFactoryRegistry().getProtocolToFactor yMap().put( "eclipselink",
> new EclipseLinkResourceFactoryImpl());
> resourceSet.getLoadOptions().putAll(getTestPersistenceUnitPr operties());
>
> final Resource resource = resourceSet.getResource(uri, true);
>
> return resource;
> }
>
>
> Now I have the question: Where do I put all of the orm.xml files? Seems
> I have a few options:
>
>
> leave them in the model bundles and add imports to all of them
> move them to the service bundle, rename them and reference them in
> persistence.xml
> try to achieve this with bundle fragments
>
>
> I do not like the first, because in principle the service should not
> have to know anything about its clients. I dislike the second a bit
> less, but essentially it has the same design flaw. The third would be
> the least in intrusive as the coupling is done at runtime by the client,
> but I am not certain if it will fly.
>
> Any thoughts or advice on this? This has to be a common scenario with
> EMF <==> Eclipselink mapping for anything but the most trivial model,
> but I have not seen any discussions around it.
>
> Many thanks,
> Joel
>
--
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: [Teneo] Having multiple orm.xml [message #557162 is a reply to message #557147] |
Sun, 05 September 2010 15:28 |
|
Thanks Martin.
In regards to Texo you indicate not RCP. I am building on top of RAP, I would guess that falls under the sever side web apps that you indicate is well supported. Is this correct?
Cheers,
Joel
Martin taal wrote on Sun, 05 September 2010 12:36 | Hi Joel,
I have the orm.xml in the model plugins. I don't see another way then letting your service layer have access to the
orm.xml as it needs to know how to persist the entities. Maybe the eclipselink newsgrooup can provide some more insights.
Btw, it can be an idea to check out the Texo project which has a better orm.xml/eclipselink support than Teneo. It
depends on your usage scenario, Texo is not for rcp environments more for server side web apps. But it can be of interest:
http://wiki.eclipse.org/Texo
http://wiki.eclipse.org/Texo#ORM.2FJPA_generation_topics
gr. Martin
|
|
|
|
Re: [Teneo] Having multiple orm.xml [message #557178 is a reply to message #557097] |
Sun, 05 September 2010 18:45 |
|
I have looked at Texo and it is not appropriate for our use case because is implies abandoning the usage of EMF at runtime. Our architecture is reliant on on using the EMF support provides for binding into the controls. Looking at Texo it appears to be more a matter of whether the client is rich rather than if one has a client side or server side usage.
Cheers,
Joel
|
|
|
Goto Forum:
Current Time: Fri Apr 26 21:43:10 GMT 2024
Powered by FUDForum. Page generated in 0.02863 seconds
|