Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Teneo EMF @OneToOne and @ManyToOne
Teneo EMF @OneToOne and @ManyToOne [message #987233] Sat, 24 November 2012 19:59 Go to next message
Svetoslav Missing name is currently offline Svetoslav Missing nameFriend
Messages: 17
Registered: July 2009
Junior Member
Hello.

I am using Teneo 2.0.1 and Hibernate 4.1.8. Here are my DataStore init options:

props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "true");
props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY, "true");
props.setProperty(PersistenceOptions.FETCH_CONTAINMENT_EAGERLY, "false");
props.setProperty(PersistenceOptions.FETCH_ASSOCIATION_EXTRA_LAZY, "true");

I'd like to use fetch=EAGER for some references in my objects. I use these annotations in ecore model: @OneToOne(fetch=EAGER) ; @ManyToOne(fetch=EAGER) ;

<eAnnotations source="teneo.jpa">
<details key="value" value="@OneToOne(fetch=EAGER)"/>
</eAnnotations>

<eAnnotations source="teneo.jpa">
<details key="value" value="@ManyToOne(fetch=EAGER)"/>
</eAnnotations>

I get the following exception:

org.eclipse.emf.teneo.annotations.parser.AnnotationParserException: The eclass: HbAnnotatedEAttribute does not have an efeature for OneToOne
org.eclipse.emf.teneo.annotations.parser.AnnotationParserException: The eclass: HbAnnotatedEAttribute does not have an efeature for OneToOne

How can I achieve loading of the needed object references?

Cheers,
Svetoslav
Re: Teneo EMF @OneToOne and @ManyToOne [message #987259 is a reply to message #987233] Sun, 25 November 2012 09:47 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Svetoslav,
It seems that you set the OneToOne/ManyToOne annotations are set on an EAttribute and not on an EReference.

If that's not the case can you post/send the ecore?

gr. Martin

On 11/24/2012 08:59 PM, Svetoslav Mising name wrote:
> Hello.
>
> I am using Teneo 2.0.1 and Hibernate 4.1.8. Here are my DataStore init options:
>
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "true"); props.setProperty(PersistenceOptions.ID_COLUMN_NAME,
> "id");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY, "true");
> props.setProperty(PersistenceOptions.FETCH_CONTAINMENT_EAGERLY, "false");
> props.setProperty(PersistenceOptions.FETCH_ASSOCIATION_EXTRA_LAZY, "true");
>
> I'd like to use fetch=EAGER for some references in my objects. I use these annotations in ecore model:
> @OneToOne(fetch=EAGER) ; @ManyToOne(fetch=EAGER) ;
>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@OneToOne(fetch=EAGER)"/>
> </eAnnotations>
>
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@ManyToOne(fetch=EAGER)"/>
> </eAnnotations>
>
> I get the following exception:
>
> org.eclipse.emf.teneo.annotations.parser.AnnotationParserException: The eclass: HbAnnotatedEAttribute does not have an
> efeature for OneToOne
> org.eclipse.emf.teneo.annotations.parser.AnnotationParserException: The eclass: HbAnnotatedEAttribute does not have an
> efeature for OneToOne
>
> How can I achieve loading of the needed object references?
>
> Cheers,
> Svetoslav


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Teneo EMF @OneToOne and @ManyToOne [message #987504 is a reply to message #987259] Mon, 26 November 2012 22:10 Go to previous messageGo to next message
Svetoslav Missing name is currently offline Svetoslav Missing nameFriend
Messages: 17
Registered: July 2009
Junior Member
Yes, you are right. I was using the greatest design pattern - copy/paste and accidentally copied @OneToOne under an attribute Smile . Thank you.

I'd like to ask one more question though (not sure if I have to open a new topic). After I switched to FETCH_ASSOCIATION_EXTRA_LAZY = "true" and FORCE_LAZY = "true" hibernate generates very wrong queries - on selects it joins completely irrelevant tables: for example I try to get Student with id = 1 but it joins University table as well (University has many Students but it is irrelevant to this query - the HQL looks like: select s from Student s where s.id=1).

Cheers,
Svetoslav

Re: Teneo EMF @OneToOne and @ManyToOne [message #987523 is a reply to message #987504] Mon, 26 November 2012 23:25 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Svetoslav,
I guess student references university, not sure why the extra joins happen, it all depends on the select behavior of
hibernate which can be influenced:
http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#performance-fetching

I would need to see the complete model or better the generated hbm to comment on this in more detail.

gr. Martin

On 11/26/2012 11:10 PM, Svetoslav Mising name wrote:
> Yes, you are right. I was using the greatest design pattern - copy/paste and accidentally copied @OneToOne under an
> attribute :) . Thank you.
> I'd like to ask one more question though (not sure if I have to open a new topic). After I switched to
> FETCH_ASSOCIATION_EXTRA_LAZY = "true" and FORCE_LAZY = "true" hibernate generates very wrong queries - on selects it
> joins completely irrelevant tables: for example I try to get Student with id = 1 but it joins University table as well
> (University has many Students but it is irrelevant to this query - the HQL looks like: select s from Student s where
> s.id=1).
>
> Cheers,
> Svetoslav
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Teneo EMF @OneToOne and @ManyToOne [message #987757 is a reply to message #987523] Tue, 27 November 2012 22:22 Go to previous message
Svetoslav Missing name is currently offline Svetoslav Missing nameFriend
Messages: 17
Registered: July 2009
Junior Member
Hi Martin,

I've just sent you the model, hbm and the generated sql by mail.

Cheers,
Svetoslav
Previous Topic:Hook to modify how xsd:double is serialized by XMLResource
Next Topic:customization templates: EPackageModelGenAnnotation not found
Goto Forum:
  


Current Time: Fri Mar 29 14:36:21 GMT 2024

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

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

Back to the top