Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » Teneo + EclipseLink simple complete example
| |
Re: Teneo + EclipseLink simple complete example [message #138114 is a reply to message #138106] |
Mon, 06 July 2009 20:25 |
Antonel Ernest Pazargic 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 #138157 is a reply to message #138147] |
Tue, 07 July 2009 22:51 |
Antonel Ernest Pazargic 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 |
Martin Taal 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 |
Antonel Ernest Pazargic 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 #621092 is a reply to message #138106] |
Mon, 06 July 2009 20:25 |
Antonel Ernest Pazargic 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 #621097 is a reply to message #138147] |
Tue, 07 July 2009 22:51 |
Antonel Ernest Pazargic 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 |
Martin Taal 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 |
Antonel Ernest Pazargic 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/
|
|
| |
Goto Forum:
Current Time: Sun Oct 06 13:06:07 GMT 2024
Powered by FUDForum. Page generated in 0.06178 seconds
|