Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Teneo + EclipseLink simple complete example
Teneo + EclipseLink simple complete example [message #138097] Mon, 06 July 2009 14:30 Go to next message
Antonel Ernest Pazargic is currently offline Antonel Ernest PazargicFriend
Messages: 69
Registered: July 2009
Member
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.
Re: Teneo + EclipseLink simple complete example [message #138106 is a reply to message #138097] Mon, 06 July 2009 18:39 Go to previous messageGo 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 #138114 is a reply to message #138106] 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 #138147 is a reply to message #138106] 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 #138157 is a reply to message #138147] 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 #138166 is a reply to message #138157] 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 #138174 is a reply to message #138166] 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 #138217 is a reply to message #138157] 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
Re: Teneo + EclipseLink simple complete example [message #621091 is a reply to message #138097] Mon, 06 July 2009 18:39 Go to previous 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 #621092 is a reply to message #138106] Mon, 06 July 2009 20:25 Go to previous 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 #621096 is a reply to message #138106] Tue, 07 July 2009 20:24 Go to previous 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 #621097 is a reply to message #138147] Tue, 07 July 2009 22:51 Go to previous 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 #621098 is a reply to message #138157] Wed, 08 July 2009 06:03 Go to previous 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 #621099 is a reply to message #138166] Wed, 08 July 2009 06:16 Go to previous 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 #621105 is a reply to message #138157] 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:[EMF Compare] Conflicting should be true, but is false
Next Topic:Migrate oAW projects to Eclipse Galileo
Goto Forum:
  


Current Time: Sun Mar 03 10:36:31 GMT 2024

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

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

Back to the top