Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: Teneo + EclipseLink simple complete example
Re: Teneo + EclipseLink simple complete example [message #431259] Mon, 06 July 2009 18:39 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Antonel,
I can answer the first and more general question. For the second question I will ask one of the other committers to react.

For 1), Teneo has to be able to choose which efeature is the id-feature. As you don't want/have jpa annotations in the
model I guess that's where the issue is. In this case you can set the EMF ID attribute of the id EAttribute to true.

Currently it is not possible to create JPA annotations in the java code itself. I have been working myself on a separate
project to generate and maintain java annotations in generated code based on EMF models but it does not yet cover jpa
annotations.

Support Teneo is given on the main EMF newsgroup which I added as cc.

gr. Martin

Antonel Ernest Pazargic wrote:
> Hi
>
> I've tried to create (from scratch) a simple example project (EMF +
> Teneo + EclipseLink) but without success.
>
> The issues I've faced are:
> 1. The Teneo > Generate ORM Files handler doesn't generate the orm:id
> tag for id feature. For the moment I've modified the orm.xml to specify
> the id for each entity.
> 2. One To Many references doesn't work. The thrown exception is:
> Exception [EclipseLink-1] (Eclipse Persistence Services -
> 1.1.2.v20090612-r4475):
> org.eclipse.persistence.exceptions.DescriptorException
> Exception Description: The attribute [books] is not declared as type
> ValueHolderInterface, but its mapping uses indirection.
> Mapping: org.eclipse.persistence.mappings.OneToManyMapping[books]
> Descriptor:
> RelationalDescriptor(ro.crito.medyna.model.library.impl.Libr aryImpl -->
> [DatabaseTable(LIBRARY)])
>
> I've certainly missed some configuration. Simple complete working
> example and useful TENEO-JPA documentation links are very welcome.
>
> I would prefer using JPA annotations in generated EMF model
> implementation classes or generate orm.xml file via TENEO tool
> generator. I would like to avoid TENEO JPA annotations in ecore file. Is
> that this possible?
>
> 10x a lot jtonic.


--

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 + EclipseLink simple complete example [message #431260 is a reply to message #431259] Mon, 06 July 2009 20:25 Go to previous messageGo to next message
Antonel Ernest Pazargic is currently offline Antonel Ernest PazargicFriend
Messages: 69
Registered: July 2009
Member
First, thanks for the very quick answer

On Mon, 06 Jul 2009 21:39:38 +0300, Martin Taal <mtaal@elver.org> wrote:

>>> For 1), Teneo has to be able to choose which efeature is the
>>> id-feature. As you don't want/have jpa annotations in the model I
>>> guess that's >>> where the issue is. In this case you can set the EMF
>>> ID attribute of the id EAttribute to true.


That's the setting I've did from the first moment but the ORM generator
stubbornly generate the same <orm:basic fetch="EAGER" name="id"
optional="false"/>, and the prototype project throws

Exception Description: Entity class [class
ro.crito.medyna.model.library.impl.LibraryImpl] has no primary key
specified. It should define either an @Id, @EmbeddedId or an @IdClass. If
you have defined PK using any of these annotations then please make sure
that you do not have mixed access-type (both fields and properties
annotated) in your entity class hierarchy.

Do I have to use @Id EAnnotation for id eattribute to achieve that? But as
I said I think these JPA EAnnotations looks hard-to-maintain to me.
I will investigate the possibility to use the new EMF/RCP/JFace
databinding/Teneo-EclipseLink/CDO in my next project, but I have only
RCP/JFace/JPA experience.
As a new-comer I've noted the lack of Teneo-EclipseLink documentation,
tutorial, articles, even after the new Galileo release was out :(, so I've
kindly asked the are some good articles for a very new comer like me.

Thanks in advance, jtonic

Note: These technologies looks promising.


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: Teneo + EclipseLink simple complete example [message #431261 is a reply to message #431260] Mon, 06 July 2009 20:50 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Antonel,
Sorry my mistake :-(, as a default Teneo-EclipseLink ignores this ID EMF attribute (this is controlled by an option).
You can either set the @Id annotation in the model or in xml or generate the orm file programmatically
(ORMGenerator.generateORM) and pass the options you want, see here for an overview of the options:
http://www.elver.org/hibernate/options.html

The Teneo-EclipseLink integration has had its first release so documentation is a topic of attention....

I am not sure if you are mapping to a legacy database in which case you need a fair amount of annotations or start with
a new project. If the last then the base philosophy of Teneo is that most/all annotations are auto-generated (in-memory)
for you based on the EMF model information. So only in case you need to manually override stuff you need to add annotations.

I have asked the core Teneo-EclipseLink committers to look at your questions so I hope that they will react soon also
(depending on the timezone they are at).

gr. Martin

Antonel Ernest Pazargic wrote:
> First, thanks for the very quick answer
>
> On Mon, 06 Jul 2009 21:39:38 +0300, Martin Taal <mtaal@elver.org> wrote:
>
>>>> For 1), Teneo has to be able to choose which efeature is the
>>>> id-feature. As you don't want/have jpa annotations in the model I
>>>> guess that's >>> where the issue is. In this case you can set the
>>>> EMF ID attribute of the id EAttribute to true.
>
>
> That's the setting I've did from the first moment but the ORM generator
> stubbornly generate the same <orm:basic fetch="EAGER" name="id"
> optional="false"/>, and the prototype project throws
>
> Exception Description: Entity class [class
> ro.crito.medyna.model.library.impl.LibraryImpl] has no primary key
> specified. It should define either an @Id, @EmbeddedId or an @IdClass.
> If you have defined PK using any of these annotations then please make
> sure that you do not have mixed access-type (both fields and properties
> annotated) in your entity class hierarchy.
>
> Do I have to use @Id EAnnotation for id eattribute to achieve that? But
> as I said I think these JPA EAnnotations looks hard-to-maintain to me.
> I will investigate the possibility to use the new EMF/RCP/JFace
> databinding/Teneo-EclipseLink/CDO in my next project, but I have only
> RCP/JFace/JPA experience.
> As a new-comer I've noted the lack of Teneo-EclipseLink documentation,
> tutorial, articles, even after the new Galileo release was out :(, so
> I've kindly asked the are some good articles for a very new comer like me.
>
> Thanks in advance, jtonic
>
> Note: These technologies looks promising.
>
>
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


--

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 + EclipseLink simple complete example [message #431265 is a reply to message #431261] Mon, 06 July 2009 21:36 Go to previous messageGo to next message
Antonel Ernest Pazargic is currently offline Antonel Ernest PazargicFriend
Messages: 69
Registered: July 2009
Member
On Mon, 06 Jul 2009 23:50:53 +0300, Martin Taal <mtaal@elver.org> wrote:

> Hi Antonel,
> Sorry my mistake :-(, as a default Teneo-EclipseLink ignores this ID EMF
> attribute (this is controlled by an option). You can either set the @Id
> annotation in the model or in xml or generate the orm file
> programmatically (ORMGenerator.generateORM) and pass the options you
> want, see here for an overview of the options:
> http://www.elver.org/hibernate/options.html

Would some generating options be good candidates for TENEO preferences?

>
> The Teneo-EclipseLink integration has had its first release so
> documentation is a topic of attention....

I'm looking forward hearing news about that. Thanks.

>
> I am not sure if you are mapping to a legacy database in which case you
> need a fair amount of annotations or start with a new project. If the
> last then the base philosophy of Teneo is that most/all annotations are
> auto-generated (in-memory) for you based on the EMF model information.
> So only in case you need to manually override stuff you need to add
> annotations.

I want to migrate a relative simple application (JBoss server, JPA
Hibernate impl, RCP-3.2) to RCP-3.5, EMF, Teneo, EclipseLink, CDO mainly
because the code generation facility, model centric architecture,
JFace/EMF databinding(that's very cool indeed), validation,
distributed/shared model, model transaction and more. Even if these
technologies are pretty cool and mature they require, as I said for, good
articles/books, at least for new comers. Of course these eclipse
newsgroups are "gold" but I think it's not enough. I will pay for good and
updated books about these technologies.


>
> I have asked the core Teneo-EclipseLink committers to look at your
> questions so I hope that they will react soon also (depending on the
> timezone they are at).
>

2 days I've googled about the OneToMany issue without success (except an
emf newsgroup entry 'EMF - Teneo-EclipseLink - @OneToMany' that said it's
a warning :( )

Thanks, jtonic

> gr. Martin
>
> Antonel Ernest Pazargic wrote:
>> First, thanks for the very quick answer
>> On Mon, 06 Jul 2009 21:39:38 +0300, Martin Taal <mtaal@elver.org>
>> wrote:
>>
>>>>> For 1), Teneo has to be able to choose which efeature is the
>>>>> id-feature. As you don't want/have jpa annotations in the model I
>>>>> guess that's >>> where the issue is. In this case you can set the
>>>>> EMF ID attribute of the id EAttribute to true.
>> That's the setting I've did from the first moment but the ORM
>> generator stubbornly generate the same <orm:basic fetch="EAGER"
>> name="id" optional="false"/>, and the prototype project throws
>> Exception Description: Entity class [class
>> ro.crito.medyna.model.library.impl.LibraryImpl] has no primary key
>> specified. It should define either an @Id, @EmbeddedId or an @IdClass.
>> If you have defined PK using any of these annotations then please make
>> sure that you do not have mixed access-type (both fields and properties
>> annotated) in your entity class hierarchy.
>> Do I have to use @Id EAnnotation for id eattribute to achieve that?
>> But as I said I think these JPA EAnnotations looks hard-to-maintain to
>> me.
>> I will investigate the possibility to use the new EMF/RCP/JFace
>> databinding/Teneo-EclipseLink/CDO in my next project, but I have only
>> RCP/JFace/JPA experience.
>> As a new-comer I've noted the lack of Teneo-EclipseLink documentation,
>> tutorial, articles, even after the new Galileo release was out :(, so
>> I've kindly asked the are some good articles for a very new comer like
>> me.
>> Thanks in advance, jtonic
>> Note: These technologies looks promising.
>> -- Using Opera's revolutionary e-mail client:
>> http://www.opera.com/mail/
>
>


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: Teneo + EclipseLink simple complete example [message #431296 is a reply to message #431259] Tue, 07 July 2009 20:24 Go to previous messageGo to next message
Shaun Smith is currently offline Shaun SmithFriend
Messages: 197
Registered: July 2009
Senior Member
Hi Antonel,

I'll leave generation questions to Martin and focus on your runtime
issue #2.

> 2. One To Many references doesn't work. The thrown exception is:
> Exception [EclipseLink-1] (Eclipse Persistence Services -
> 1.1.2.v20090612-r4475):
> org.eclipse.persistence.exceptions.DescriptorException
> Exception Description: The attribute [books] is not declared as type
> ValueHolderInterface, but its mapping uses indirection.
> Mapping: org.eclipse.persistence.mappings.OneToManyMapping[books]
> Descriptor:
> RelationalDescriptor(ro.crito.medyna.model.library.impl.Libr aryImpl -->
> [DatabaseTable(LIBRARY)])

Can you post the generated mapping for LibraryImpl and the definition of
the books attribute from your class? Is it defined as an ELIst or EMap?

> I've certainly missed some configuration. Simple complete working example
> and useful TENEO-JPA documentation links are very welcome.

The Expanded library example illustrates a large number of combinations of
EMF configurations and their associated mappings. I've updated the
"Getting Started" page (http://wiki.eclipse.org/EMF/Teneo/EclipseLink_JPA)
for Galileo and started a page to catalog the various mapping idioms
employed in the example
( http://wiki.eclipse.org/EMF/Teneo/EclipseLink/Understanding_ JPA_Mapping).

> I would prefer using JPA annotations in generated EMF model implementation
> classes or generate orm.xml file via TENEO tool generator. I would like to
> avoid TENEO JPA annotations in ecore file. Is that this possible?

If you were to generate everything from your Ecore model this is a
possibility and something I believe Martin is looking at. But if you're
generating everything from Ecore then why do you care where your mappings
are?

Now if you are doing a "meet in the middle mapping" where you take an
existing EMF model and map it with JPA (perhaps using Dali) I would
recommend a mapping file to avoid overwriting your annotations if/when you
regenerated your impl classes.

--Shaun
Re: Teneo + EclipseLink simple complete example [message #431303 is a reply to message #431296] Tue, 07 July 2009 22:51 Go to previous messageGo to next message
Antonel Ernest Pazargic is currently offline Antonel Ernest PazargicFriend
Messages: 69
Registered: July 2009
Member
On Tue, 07 Jul 2009 23:24:04 +0300, Shaun Smith <shaun.smith@oracle.com>
wrote:

> Hi Antonel,
>
> I'll leave generation questions to Martin and focus on your runtime
> issue #2.
>
>> 2. One To Many references doesn't work. The thrown exception is:
>> Exception [EclipseLink-1] (Eclipse Persistence Services -
>> 1.1.2.v20090612-r4475):
>> org.eclipse.persistence.exceptions.DescriptorException
>> Exception Description: The attribute [books] is not declared as type
>> ValueHolderInterface, but its mapping uses indirection.
>> Mapping: org.eclipse.persistence.mappings.OneToManyMapping[books]
>> Descriptor:
>> RelationalDescriptor(ro.crito.medyna.model.library.impl.Libr aryImpl
>> --> [DatabaseTable(LIBRARY)])
>
> Can you post the generated mapping for LibraryImpl and the definition of
> the books attribute from your class? Is it defined as an ELIst or EMap?

orm.xml
=========
<orm:mapped-superclass
class="ro.crito.medyna.model.library.impl.IdentifiableImpl" >
<orm:attributes>
<orm:id name="id">
<orm:generated-value strategy="AUTO"/>
</orm:id>
<orm:basic name="eContainerFeatureID">
<orm:column name="ECONT_FEAT_ID"/>
</orm:basic>
<orm:version name="version"/>
</orm:attributes>
</orm:mapped-superclass>
<orm:entity class="ro.crito.medyna.model.library.impl.BookImpl"
name="Book">
<orm:table name="BOOK"/>
<orm:inheritance strategy="JOINED"/>
<orm:attributes>
<orm:basic fetch="EAGER" name="title" optional="false"/>
<orm:many-to-one name="eContainer"
target-entity="ro.crito.medyna.model.library.impl.LibraryImpl ">
<orm:join-column name="BOOK_LIBRARY_ID"/>
<orm:cascade>
<orm:cascade-all/>
</orm:cascade>
</orm:many-to-one>
</orm:attributes>
</orm:entity>
<orm:entity class="ro.crito.medyna.model.library.impl.LibraryImpl"
name="Library">
<orm:table name="LIBRARY"/>
<orm:inheritance strategy="JOINED"/>
<orm:attributes>
<orm:basic fetch="EAGER" name="name" optional="false"/>
<orm:one-to-many fetch="LAZY" name="books"
target-entity="ro.crito.medyna.model.library.impl.BookImpl" >
<orm:join-column insertable="true" name="BOOK_LIBRARY_ID"
nullable="true" unique="false" updatable="true"/>
<orm:cascade>
<orm:cascade-all/>
</orm:cascade>
</orm:one-to-many>
</orm:attributes>
</orm:entity>
</orm:entity-mappings>
=========

public class LibraryImpl extends IdentifiableImpl implements Library {
....

protected EList<Book> books;
....

public EList<Book> getBooks() {
if (books == null) {
books = new EObjectContainmentWithInverseEList<Book>(Book.class, this,
LibraryPackage.LIBRARY__BOOKS, LibraryPackage.BOOK__LIBRARY);
}
return books;
}

....
}

client plugin
===========

Library l = LibraryFactory.eINSTANCE.createLibrary();
l.setName("Library 1");

Book b1 = LibraryFactory.eINSTANCE.createBook();
b1.setTitle("Book 1");

l.getBooks().add(b1);
b1.setLibrary(l);

String query =
EclipseLinkURIUtil.createContentsInstancesOfQuery(LibraryPac kage.eINSTANCE.getLibrary());
URI uri = EclipseLinkURIUtil.createEclipseLinkURI("library", query);

// save all library model instances in database
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getLoadOptions().putAll(getTestPersistenceUnitPr operties(Library.class.getClassLoader()));
Resource resource = resourceSet.createResource(uri);
resource.getContents().add(l);
resource.save(Collections.EMPTY_MAP);
==========

The RCP application has 2 plugins:
1. model - contains ecore, persistence.xml, orm.xml, generated code;
2. ui - contains the emf resource saving operation

>
>> I've certainly missed some configuration. Simple complete working
>> example and useful TENEO-JPA documentation links are very welcome.
>
> The Expanded library example illustrates a large number of combinations
> of EMF configurations and their associated mappings. I've updated the
> "Getting Started" page
> (http://wiki.eclipse.org/EMF/Teneo/EclipseLink_JPA) for Galileo and
> started a page to catalog the various mapping idioms employed in the
> example
> ( http://wiki.eclipse.org/EMF/Teneo/EclipseLink/Understanding_ JPA_Mapping).
>
>> I would prefer using JPA annotations in generated EMF model
>> implementation classes or generate orm.xml file via TENEO tool
>> generator. I would like to avoid TENEO JPA annotations in ecore file.
>> Is that this possible?
>
> If you were to generate everything from your Ecore model this is a
> possibility and something I believe Martin is looking at. But if you're
> generating everything from Ecore then why do you care where your
> mappings are?

Because the good IDE support in java editor (content assist, quick fix,
validation, maybe refactoring) and good suport in dali persistence.xml
editor.

>
> Now if you are doing a "meet in the middle mapping" where you take an
> existing EMF model and map it with JPA (perhaps using Dali) I would
> recommend a mapping file to avoid overwriting your annotations if/when
> you regenerated your impl classes.

I faced some problems with Dali and Teneo:
- Teneo generate orm.xml file in the same folder with library.ecore and
dali only looks for the orm.xml file in src directory;
- The generated orm.xml contains qualified names for elements (<orm:bla)
and dali complains about unrecognized orm.xml file.
But after some labor work :(, dali become happy:). So when I've tried to
generate tables from entities the same exception occurs
(ValueHolderInterface blablabla :()

Thx in advance, jtonic

>
> --Shaun
>
>


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: Teneo + EclipseLink simple complete example [message #431305 is a reply to message #431303] Wed, 08 July 2009 06:03 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Antonel,
Can you enter a bugzilla for the qualified item in the xml you mention? Then I can pick it up in the next build.

gr. Martin

Antonel Ernest Pazargic wrote:
> On Tue, 07 Jul 2009 23:24:04 +0300, Shaun Smith <shaun.smith@oracle.com>
> wrote:
>
>> Hi Antonel,
>>
>> I'll leave generation questions to Martin and focus on your runtime
>> issue #2.
>>
>>> 2. One To Many references doesn't work. The thrown exception is:
>>> Exception [EclipseLink-1] (Eclipse Persistence Services -
>>> 1.1.2.v20090612-r4475):
>>> org.eclipse.persistence.exceptions.DescriptorException
>>> Exception Description: The attribute [books] is not declared as type
>>> ValueHolderInterface, but its mapping uses indirection.
>>> Mapping: org.eclipse.persistence.mappings.OneToManyMapping[books]
>>> Descriptor:
>>> RelationalDescriptor(ro.crito.medyna.model.library.impl.Libr aryImpl
>>> --> [DatabaseTable(LIBRARY)])
>>
>> Can you post the generated mapping for LibraryImpl and the definition
>> of the books attribute from your class? Is it defined as an ELIst or
>> EMap?
>
> orm.xml
> =========
> <orm:mapped-superclass
> class="ro.crito.medyna.model.library.impl.IdentifiableImpl" >
> <orm:attributes>
> <orm:id name="id">
> <orm:generated-value strategy="AUTO"/>
> </orm:id>
> <orm:basic name="eContainerFeatureID">
> <orm:column name="ECONT_FEAT_ID"/>
> </orm:basic>
> <orm:version name="version"/>
> </orm:attributes>
> </orm:mapped-superclass>
> <orm:entity class="ro.crito.medyna.model.library.impl.BookImpl"
> name="Book">
> <orm:table name="BOOK"/>
> <orm:inheritance strategy="JOINED"/>
> <orm:attributes>
> <orm:basic fetch="EAGER" name="title" optional="false"/>
> <orm:many-to-one name="eContainer"
> target-entity="ro.crito.medyna.model.library.impl.LibraryImpl ">
> <orm:join-column name="BOOK_LIBRARY_ID"/>
> <orm:cascade>
> <orm:cascade-all/>
> </orm:cascade>
> </orm:many-to-one>
> </orm:attributes>
> </orm:entity>
> <orm:entity class="ro.crito.medyna.model.library.impl.LibraryImpl"
> name="Library">
> <orm:table name="LIBRARY"/>
> <orm:inheritance strategy="JOINED"/>
> <orm:attributes>
> <orm:basic fetch="EAGER" name="name" optional="false"/>
> <orm:one-to-many fetch="LAZY" name="books"
> target-entity="ro.crito.medyna.model.library.impl.BookImpl" >
> <orm:join-column insertable="true" name="BOOK_LIBRARY_ID"
> nullable="true" unique="false" updatable="true"/>
> <orm:cascade>
> <orm:cascade-all/>
> </orm:cascade>
> </orm:one-to-many>
> </orm:attributes>
> </orm:entity>
> </orm:entity-mappings>
> =========
>
> public class LibraryImpl extends IdentifiableImpl implements Library {
> ....
>
> protected EList<Book> books;
> ....
>
> public EList<Book> getBooks() {
> if (books == null) {
> books = new
> EObjectContainmentWithInverseEList<Book>(Book.class, this,
> LibraryPackage.LIBRARY__BOOKS, LibraryPackage.BOOK__LIBRARY);
> }
> return books;
> }
>
> ....
> }
>
> client plugin
> ===========
>
> Library l = LibraryFactory.eINSTANCE.createLibrary();
> l.setName("Library 1");
>
> Book b1 = LibraryFactory.eINSTANCE.createBook();
> b1.setTitle("Book 1");
>
> l.getBooks().add(b1);
> b1.setLibrary(l);
>
> String query =
> EclipseLinkURIUtil.createContentsInstancesOfQuery(LibraryPac kage.eINSTANCE.getLibrary());
>
> URI uri = EclipseLinkURIUtil.createEclipseLinkURI("library",
> query);
>
> // save all library model instances in database
> ResourceSet resourceSet = new ResourceSetImpl();
>
> resourceSet.getLoadOptions().putAll(getTestPersistenceUnitPr operties(Library.class.getClassLoader()));
>
> Resource resource = resourceSet.createResource(uri);
> resource.getContents().add(l);
> resource.save(Collections.EMPTY_MAP);
> ==========
>
> The RCP application has 2 plugins:
> 1. model - contains ecore, persistence.xml, orm.xml, generated code;
> 2. ui - contains the emf resource saving operation
>
>>
>>> I've certainly missed some configuration. Simple complete working
>>> example and useful TENEO-JPA documentation links are very welcome.
>>
>> The Expanded library example illustrates a large number of
>> combinations of EMF configurations and their associated mappings.
>> I've updated the "Getting Started" page
>> (http://wiki.eclipse.org/EMF/Teneo/EclipseLink_JPA) for Galileo and
>> started a page to catalog the various mapping idioms employed in the
>> example
>> ( http://wiki.eclipse.org/EMF/Teneo/EclipseLink/Understanding_ JPA_Mapping).
>>
>>
>>> I would prefer using JPA annotations in generated EMF model
>>> implementation classes or generate orm.xml file via TENEO tool
>>> generator. I would like to avoid TENEO JPA annotations in ecore
>>> file. Is that this possible?
>>
>> If you were to generate everything from your Ecore model this is a
>> possibility and something I believe Martin is looking at. But if
>> you're generating everything from Ecore then why do you care where
>> your mappings are?
>
> Because the good IDE support in java editor (content assist, quick fix,
> validation, maybe refactoring) and good suport in dali persistence.xml
> editor.
>
>>
>> Now if you are doing a "meet in the middle mapping" where you take an
>> existing EMF model and map it with JPA (perhaps using Dali) I would
>> recommend a mapping file to avoid overwriting your annotations if/when
>> you regenerated your impl classes.
>
> I faced some problems with Dali and Teneo:
> - Teneo generate orm.xml file in the same folder with library.ecore and
> dali only looks for the orm.xml file in src directory;
> - The generated orm.xml contains qualified names for elements (<orm:bla)
> and dali complains about unrecognized orm.xml file.
> But after some labor work :(, dali become happy:). So when I've tried to
> generate tables from entities the same exception occurs
> (ValueHolderInterface blablabla :()
>
> Thx in advance, jtonic
>
>>
>> --Shaun
>>
>>
>
>


--

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 + EclipseLink simple complete example [message #431306 is a reply to message #431305] Wed, 08 July 2009 06:16 Go to previous messageGo to next message
Antonel Ernest Pazargic is currently offline Antonel Ernest PazargicFriend
Messages: 69
Registered: July 2009
Member
On Wed, 08 Jul 2009 09:03:30 +0300, Martin Taal <mtaal@elver.org> wrote:

I've missed the following configuration in persistence.xml:

<property name="eclipselink.session.customizer"
value="org.eclipse.emf.teneo.eclipselink.EmfSessionCustomizer "/>

> Hi Antonel,
> Can you enter a bugzilla for the qualified item in the xml you mention?
> Then I can pick it up in the next build.
>

It seems that the namespace xml:orm is the problem if I replace all
'<orm:bla' with '<bla' all is OK to Dali, otherwise Dali complain "Mapping
file "META-INF/orm.xml does not have ORM content".

Thanks again for your quick support, Martin Taal, Shaun Smith and
community.

> gr. Martin
>
> Antonel Ernest Pazargic wrote:
>> On Tue, 07 Jul 2009 23:24:04 +0300, Shaun Smith
>> <shaun.smith@oracle.com> wrote:
>>
>>> Hi Antonel,
>>>
>>> I'll leave generation questions to Martin and focus on your runtime
>>> issue #2.
>>>
>>>> 2. One To Many references doesn't work. The thrown exception is:
>>>> Exception [EclipseLink-1] (Eclipse Persistence Services -
>>>> 1.1.2.v20090612-r4475):
>>>> org.eclipse.persistence.exceptions.DescriptorException
>>>> Exception Description: The attribute [books] is not declared as type
>>>> ValueHolderInterface, but its mapping uses indirection.
>>>> Mapping: org.eclipse.persistence.mappings.OneToManyMapping[books]
>>>> Descriptor:
>>>> RelationalDescriptor(ro.crito.medyna.model.library.impl.Libr aryImpl
>>>> --> [DatabaseTable(LIBRARY)])
>>>
>>> Can you post the generated mapping for LibraryImpl and the definition
>>> of the books attribute from your class? Is it defined as an ELIst or
>>> EMap?
>> orm.xml
>> =========
>> <orm:mapped-superclass
>> class="ro.crito.medyna.model.library.impl.IdentifiableImpl" >
>> <orm:attributes>
>> <orm:id name="id">
>> <orm:generated-value strategy="AUTO"/>
>> </orm:id>
>> <orm:basic name="eContainerFeatureID">
>> <orm:column name="ECONT_FEAT_ID"/>
>> </orm:basic>
>> <orm:version name="version"/>
>> </orm:attributes>
>> </orm:mapped-superclass>
>> <orm:entity class="ro.crito.medyna.model.library.impl.BookImpl"
>> name="Book">
>> <orm:table name="BOOK"/>
>> <orm:inheritance strategy="JOINED"/>
>> <orm:attributes>
>> <orm:basic fetch="EAGER" name="title" optional="false"/>
>> <orm:many-to-one name="eContainer"
>> target-entity="ro.crito.medyna.model.library.impl.LibraryImpl ">
>> <orm:join-column name="BOOK_LIBRARY_ID"/>
>> <orm:cascade>
>> <orm:cascade-all/>
>> </orm:cascade>
>> </orm:many-to-one>
>> </orm:attributes>
>> </orm:entity>
>> <orm:entity class="ro.crito.medyna.model.library.impl.LibraryImpl"
>> name="Library">
>> <orm:table name="LIBRARY"/>
>> <orm:inheritance strategy="JOINED"/>
>> <orm:attributes>
>> <orm:basic fetch="EAGER" name="name" optional="false"/>
>> <orm:one-to-many fetch="LAZY" name="books"
>> target-entity="ro.crito.medyna.model.library.impl.BookImpl" >
>> <orm:join-column insertable="true" name="BOOK_LIBRARY_ID"
>> nullable="true" unique="false" updatable="true"/>
>> <orm:cascade>
>> <orm:cascade-all/>
>> </orm:cascade>
>> </orm:one-to-many>
>> </orm:attributes>
>> </orm:entity>
>> </orm:entity-mappings>
>> =========
>> public class LibraryImpl extends IdentifiableImpl implements Library {
>> ....
>> protected EList<Book> books;
>> ....
>> public EList<Book> getBooks() {
>> if (books == null) {
>> books = new
>> EObjectContainmentWithInverseEList<Book>(Book.class, this,
>> LibraryPackage.LIBRARY__BOOKS, LibraryPackage.BOOK__LIBRARY);
>> }
>> return books;
>> }
>> ....
>> }
>> client plugin
>> ===========
>> Library l = LibraryFactory.eINSTANCE.createLibrary();
>> l.setName("Library 1");
>> Book b1 = LibraryFactory.eINSTANCE.createBook();
>> b1.setTitle("Book 1");
>> l.getBooks().add(b1);
>> b1.setLibrary(l);
>> String query =
>> EclipseLinkURIUtil.createContentsInstancesOfQuery(LibraryPac kage.eINSTANCE.getLibrary());
>> URI uri = EclipseLinkURIUtil.createEclipseLinkURI("library",
>> query);
>> // save all library model instances in database
>> ResourceSet resourceSet = new ResourceSetImpl();
>>
>> resourceSet.getLoadOptions().putAll(getTestPersistenceUnitPr operties(Library.class.getClassLoader()));
>> Resource resource = resourceSet.createResource(uri);
>> resource.getContents().add(l);
>> resource.save(Collections.EMPTY_MAP);
>> ==========
>> The RCP application has 2 plugins:
>> 1. model - contains ecore, persistence.xml, orm.xml, generated code;
>> 2. ui - contains the emf resource saving operation
>>
>>>
>>>> I've certainly missed some configuration. Simple complete working
>>>> example and useful TENEO-JPA documentation links are very welcome.
>>>
>>> The Expanded library example illustrates a large number of
>>> combinations of EMF configurations and their associated mappings.
>>> I've updated the "Getting Started" page
>>> (http://wiki.eclipse.org/EMF/Teneo/EclipseLink_JPA) for Galileo and
>>> started a page to catalog the various mapping idioms employed in the
>>> example
>>> ( http://wiki.eclipse.org/EMF/Teneo/EclipseLink/Understanding_ JPA_Mapping).
>>>> I would prefer using JPA annotations in generated EMF model
>>>> implementation classes or generate orm.xml file via TENEO tool
>>>> generator. I would like to avoid TENEO JPA annotations in ecore
>>>> file. Is that this possible?
>>>
>>> If you were to generate everything from your Ecore model this is a
>>> possibility and something I believe Martin is looking at. But if
>>> you're generating everything from Ecore then why do you care where
>>> your mappings are?
>> Because the good IDE support in java editor (content assist, quick
>> fix, validation, maybe refactoring) and good suport in dali
>> persistence.xml editor.
>>
>>>
>>> Now if you are doing a "meet in the middle mapping" where you take an
>>> existing EMF model and map it with JPA (perhaps using Dali) I would
>>> recommend a mapping file to avoid overwriting your annotations if/when
>>> you regenerated your impl classes.
>> I faced some problems with Dali and Teneo:
>> - Teneo generate orm.xml file in the same folder with library.ecore and
>> dali only looks for the orm.xml file in src directory;
>> - The generated orm.xml contains qualified names for elements
>> (<orm:bla) and dali complains about unrecognized orm.xml file.
>> But after some labor work :(, dali become happy:). So when I've tried
>> to generate tables from entities the same exception occurs
>> (ValueHolderInterface blablabla :()
>> Thx in advance, jtonic
>>
>>>
>>> --Shaun
>>>
>>>
>>
>
>


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: Teneo + EclipseLink simple complete example [message #431421 is a reply to message #431303] Wed, 08 July 2009 17:40 Go to previous message
Shaun Smith is currently offline Shaun SmithFriend
Messages: 197
Registered: July 2009
Senior Member
Antonel Ernest Pazargic wrote:

>> If you were to generate everything from your Ecore model this is a
>> possibility and something I believe Martin is looking at. But if you're
>> generating everything from Ecore then why do you care where your
>> mappings are?

> Because the good IDE support in java editor (content assist, quick fix,
> validation, maybe refactoring) and good suport in dali persistence.xml
> editor.

But if you're generating everything you don't need good Java editor
support. :-) And Dali fully supports both Java and XML mapping for JPA so
either way you get the same level of functionality.

BTW, I've updated the expanded Library example orm.xml to remove the
<column> mapping for eContainerFeatureID in IdentifiableImpl. It doesn't
change the example functionally but avoids a Dali bug
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=282893).

--Shaun
Previous Topic:[CDO] path variable
Next Topic:[CDO] Little patch for setting up the CDO sources workspace
Goto Forum:
  


Current Time: Thu Apr 25 13:14:32 GMT 2024

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

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

Back to the top