Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Is there a way to stop initialize a collection when I only want to add or remove an element?
[Teneo] Is there a way to stop initialize a collection when I only want to add or remove an element? [message #82885] Thu, 10 May 2007 10:54 Go to next message
Anthony Lee is currently offline Anthony LeeFriend
Messages: 114
Registered: July 2009
Senior Member
Hi,

When I want to add an element to a lazy collection, the collection is
initilized.

According to below Q&A,I set my collection's inverse attribute as "true",
But the collection still be initialized.

Has this issue something to do with Teneo's persistableEList?

How can I prevent this loading?

============================================================ =============
Q:Why does Hibernate always initialize a collection when I only want to add
or remove an element?

A:Unfortunately the collections API defines method return values that may
only be computed by hitting the database. There are three exceptions to
this: Hibernate can add to a <bag>, <idbag> or <list> declared with
inverse="true" without initializing the collection; the return value must
always be true.

If you want to avoid extra database traffic (ie. in performance critical
code), refactor your model to use only many-to-one associations. This is
almost always possible. Then use queries in place of collection access.
============================================================ ==============
Re: [Teneo] Is there a way to stop initialize a collection when I only want to add or remove an elem [message #82900 is a reply to message #82885] Thu, 10 May 2007 11:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes, this is is currently how Teneo works. You can enter a bugzilla for this but I am not sure if it
is solvable. Also I am currently very busy so it will be a probably 2 weeks before the next teneo
release.

As the hb faq says another option (if you control the model): then for the large collections you can
also choose to change them to many-to-one's (so only persist the reference from the child to the
parent) and load the one-to-many relation (parent to child) on demand through an explicit query
(make the many-reference from the parent to the child transient).
Adding to the parent is then done by setting the parent feature in the child.

gr. Martin

Anthony wrote:
> Hi,
>
> When I want to add an element to a lazy collection, the collection is
> initilized.
>
> According to below Q&A,I set my collection's inverse attribute as "true",
> But the collection still be initialized.
>
> Has this issue something to do with Teneo's persistableEList?
>
> How can I prevent this loading?
>
> ============================================================ =============
> Q:Why does Hibernate always initialize a collection when I only want to add
> or remove an element?
>
> A:Unfortunately the collections API defines method return values that may
> only be computed by hitting the database. There are three exceptions to
> this: Hibernate can add to a <bag>, <idbag> or <list> declared with
> inverse="true" without initializing the collection; the return value must
> always be true.
>
> If you want to avoid extra database traffic (ie. in performance critical
> code), refactor your model to use only many-to-one associations. This is
> almost always possible. Then use queries in place of collection access.
> ============================================================ ==============
>
>
>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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] Is there a way to stop initialize a collection when I only want to add or remove an elem [message #82916 is a reply to message #82900] Thu, 10 May 2007 11:12 Go to previous message
Anthony Lee is currently offline Anthony LeeFriend
Messages: 114
Registered: July 2009
Senior Member
Martin Taal <mtaal@elver.org> wrote in
news:f1uueb$g3u$1@build.eclipse.org:

> Yes, this is is currently how Teneo works. You can enter a bugzilla
> for this but I am not sure if it is solvable. Also I am currently very
> busy so it will be a probably 2 weeks before the next teneo release.
>
> As the hb faq says another option (if you control the model): then for
> the large collections you can also choose to change them to
> many-to-one's (so only persist the reference from the child to the
> parent) and load the one-to-many relation (parent to child) on demand
> through an explicit query (make the many-reference from the parent to
> the child transient). Adding to the parent is then done by setting the
> parent feature in the child.
>
> gr. Martin
>
> Anthony wrote:
>> Hi,
>>
>> When I want to add an element to a lazy collection, the collection is
>> initilized.
>>
>> According to below Q&A,I set my collection's inverse attribute as
>> "true", But the collection still be initialized.
>>
>> Has this issue something to do with Teneo's persistableEList?
>>
>> How can I prevent this loading?
>>
>>
============================================================ ==========
>> === Q:Why does Hibernate always initialize a collection when I only
>> want to add or remove an element?
>>
>> A:Unfortunately the collections API defines method return values that
>> may only be computed by hitting the database. There are three
>> exceptions to this: Hibernate can add to a <bag>, <idbag> or <list>
>> declared with inverse="true" without initializing the collection; the
>> return value must always be true.
>>
>> If you want to avoid extra database traffic (ie. in performance
>> critical code), refactor your model to use only many-to-one
>> associations. This is almost always possible. Then use queries in
>> place of collection access.
>>
============================================================ ==========
>> ====
>>
>>
>>
>>
>>
>>
>
>

I see, Thanks .


Anthony
Re: [Teneo] Is there a way to stop initialize a collection when I only want to add or remove an elem [message #606656 is a reply to message #82885] Thu, 10 May 2007 11:07 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes, this is is currently how Teneo works. You can enter a bugzilla for this but I am not sure if it
is solvable. Also I am currently very busy so it will be a probably 2 weeks before the next teneo
release.

As the hb faq says another option (if you control the model): then for the large collections you can
also choose to change them to many-to-one's (so only persist the reference from the child to the
parent) and load the one-to-many relation (parent to child) on demand through an explicit query
(make the many-reference from the parent to the child transient).
Adding to the parent is then done by setting the parent feature in the child.

gr. Martin

Anthony wrote:
> Hi,
>
> When I want to add an element to a lazy collection, the collection is
> initilized.
>
> According to below Q&A,I set my collection's inverse attribute as "true",
> But the collection still be initialized.
>
> Has this issue something to do with Teneo's persistableEList?
>
> How can I prevent this loading?
>
> ============================================================ =============
> Q:Why does Hibernate always initialize a collection when I only want to add
> or remove an element?
>
> A:Unfortunately the collections API defines method return values that may
> only be computed by hitting the database. There are three exceptions to
> this: Hibernate can add to a <bag>, <idbag> or <list> declared with
> inverse="true" without initializing the collection; the return value must
> always be true.
>
> If you want to avoid extra database traffic (ie. in performance critical
> code), refactor your model to use only many-to-one associations. This is
> almost always possible. Then use queries in place of collection access.
> ============================================================ ==============
>
>
>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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] Is there a way to stop initialize a collection when I only want to add or remove an elem [message #606657 is a reply to message #82900] Thu, 10 May 2007 11:12 Go to previous message
Anthony Lee is currently offline Anthony LeeFriend
Messages: 114
Registered: July 2009
Senior Member
Martin Taal <mtaal@elver.org> wrote in
news:f1uueb$g3u$1@build.eclipse.org:

> Yes, this is is currently how Teneo works. You can enter a bugzilla
> for this but I am not sure if it is solvable. Also I am currently very
> busy so it will be a probably 2 weeks before the next teneo release.
>
> As the hb faq says another option (if you control the model): then for
> the large collections you can also choose to change them to
> many-to-one's (so only persist the reference from the child to the
> parent) and load the one-to-many relation (parent to child) on demand
> through an explicit query (make the many-reference from the parent to
> the child transient). Adding to the parent is then done by setting the
> parent feature in the child.
>
> gr. Martin
>
> Anthony wrote:
>> Hi,
>>
>> When I want to add an element to a lazy collection, the collection is
>> initilized.
>>
>> According to below Q&A,I set my collection's inverse attribute as
>> "true", But the collection still be initialized.
>>
>> Has this issue something to do with Teneo's persistableEList?
>>
>> How can I prevent this loading?
>>
>>
============================================================ ==========
>> === Q:Why does Hibernate always initialize a collection when I only
>> want to add or remove an element?
>>
>> A:Unfortunately the collections API defines method return values that
>> may only be computed by hitting the database. There are three
>> exceptions to this: Hibernate can add to a <bag>, <idbag> or <list>
>> declared with inverse="true" without initializing the collection; the
>> return value must always be true.
>>
>> If you want to avoid extra database traffic (ie. in performance
>> critical code), refactor your model to use only many-to-one
>> associations. This is almost always possible. Then use queries in
>> place of collection access.
>>
============================================================ ==========
>> ====
>>
>>
>>
>>
>>
>>
>
>

I see, Thanks .


Anthony
Previous Topic:[Teneo] Is there a way to stop initialize a collection when I only want to add or remove an element?
Next Topic:[Teneo] IdentifierCacheHandler and @Proxy annotation
Goto Forum:
  


Current Time: Mon Jan 18 08:46:20 GMT 2021

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

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

Back to the top