Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: [Teneo] Lazy-loading one-to-many EList
Re: [Teneo] Lazy-loading one-to-many EList [message #490921] Mon, 12 October 2009 11:53 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Frank,
Afaics the list is mapped with lazy=true, so it should be lazily-loaded. Or do you see something different?
Is it maybe that you expect the content of the lazy-loaded list to also be proxied objects. Afaik Hibernate does not use
proxies for content of a collection.
Also if you check the collection in a debugger then this may load the list. So the best is to enable hibernate sql
logging to see at which point hibernate fires certain queries.

Btw, support for Teneo is given on the main EMF newsgroupo which I added to the cc.

gr. Martin

Frank Grimm wrote:
> Dear newsgroup,
>
> I've got a beginners question regarding Teneo (in combination wiht
> Hibernate and H2 DB): I'm struggling with lazy-loading an EList. The
> model looks like this:
>
> [ EClass ] [ EClass ]
> [ M ] <>---(0..*)-> [ N ]
> [(extends Base)] [(extends Base)]
>
> I.e. an instance of M owns many instances N.
>
> Base is an abstract class with a property 'name' of type 'EString.'
>
> Even though I set PersistenceOptions.SET_PROXY to true, I'm not able to
> turn M's getter for Ns (EList<N> getNs()) into a lazy-loaded EList.
>
> The Hibernate mapping generated by Teneo looks like this:
>
> <subclass name="teneotests.test1_1toM.impl.MImpl"
> entity-name="M" abstract="false" lazy="true" extends="Base"
> discriminator-value="M" proxy="teneotests.test1_1toM.M">
> <meta attribute="eclassName">M</meta>
> <meta attribute="epackage">http://test1_1toM</meta>
> <list name="ns" lazy="true" cascade="all,delete-orphan">
> <key update="true" foreign-key="m_ns">
> <column name="`m_ns_name`"
> not-null="false" unique="false"/>
> </key>
> <list-index column="`m_ns_idx`"/>
> <one-to-many entity-name="N"/>
> </list>
> </subclass>
> <subclass name="teneotests.test1_1toM.impl.NImpl" entity-name="N"
> abstract="false" lazy="true" extends="Base"
> discriminator-value="N" proxy="teneotests.test1_1toM.N">
> <meta attribute="eclassName">N</meta>
> <meta attribute="epackage">http://test1_1toM</meta>
> </subclass>
>
> I'm not sure whether the problem has to do with M's one-to-many mapping
> not having its lazy attribute set to true.?
>
> Lazy loading works for one-to-one references; then a
> JavassistLazyInitializer is created instead of a proper EList
> implementation.
>
> Many thanks in advance,
> Frank


--

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] Lazy-loading one-to-many EList [message #491072 is a reply to message #490921] Tue, 13 October 2009 07:07 Go to previous message
Frank Grimm is currently offline Frank GrimmFriend
Messages: 22
Registered: July 2009
Junior Member
Dear Martin,

thank you for your prompt reply!

On 10/12/2009 01:53 PM, Martin Taal wrote:

> Afaics the list is mapped with lazy=true, so it should be lazily-loaded.

Indeed, the list is lazily loaded.

> Or do you see something different?
> Is it maybe that you expect the content of the lazy-loaded list to also
> be proxied objects. Afaik Hibernate does not use proxies for content of
> a collection.

Arrg, I mistook proxying for lazy loading.

> Also if you check the collection in a debugger then this may load the
> list.

Yep, that was what made me think the list wasn't lazily loaded.

> Btw, support for Teneo is given on the main EMF newsgroupo which I added
> to the cc.

Alright, thanks, will post there next time I've got a Teneo related
question.

Thanks,
Frank

> Frank Grimm wrote:
>> Dear newsgroup,
>>
>> I've got a beginners question regarding Teneo (in combination wiht
>> Hibernate and H2 DB): I'm struggling with lazy-loading an EList. The
>> model looks like this:
>>
>> [ EClass ] [ EClass ]
>> [ M ] <>---(0..*)-> [ N ]
>> [(extends Base)] [(extends Base)]
>>
>> I.e. an instance of M owns many instances N.
>>
>> Base is an abstract class with a property 'name' of type 'EString.'
>>
>> Even though I set PersistenceOptions.SET_PROXY to true, I'm not able to
>> turn M's getter for Ns (EList<N> getNs()) into a lazy-loaded EList.
>>
>> The Hibernate mapping generated by Teneo looks like this:
>>
>> <subclass name="teneotests.test1_1toM.impl.MImpl"
>> entity-name="M" abstract="false" lazy="true" extends="Base"
>> discriminator-value="M" proxy="teneotests.test1_1toM.M">
>> <meta attribute="eclassName">M</meta>
>> <meta attribute="epackage">http://test1_1toM</meta>
>> <list name="ns" lazy="true" cascade="all,delete-orphan">
>> <key update="true" foreign-key="m_ns">
>> <column name="`m_ns_name`"
>> not-null="false" unique="false"/>
>> </key>
>> <list-index column="`m_ns_idx`"/>
>> <one-to-many entity-name="N"/>
>> </list>
>> </subclass>
>> <subclass name="teneotests.test1_1toM.impl.NImpl" entity-name="N"
>> abstract="false" lazy="true" extends="Base"
>> discriminator-value="N" proxy="teneotests.test1_1toM.N">
>> <meta attribute="eclassName">N</meta>
>> <meta attribute="epackage">http://test1_1toM</meta>
>> </subclass>
>>
>> I'm not sure whether the problem has to do with M's one-to-many mapping
>> not having its lazy attribute set to true.?
>>
>> Lazy loading works for one-to-one references; then a
>> JavassistLazyInitializer is created instead of a proper EList
>> implementation.
>>
>> Many thanks in advance,
>> Frank
>
>
Previous Topic:StackOverflow Error in Eclipse Galileo and TopCased 3.1.0
Next Topic:[Teneo] how do I change e_id to <class>_id
Goto Forum:
  


Current Time: Thu Apr 25 03:55:05 GMT 2024

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

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

Back to the top