Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Resolving lists
[Teneo] Resolving lists [message #84785] Thu, 24 May 2007 19:56 Go to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

Is there a way to tell Teneo not to resolve a list? I have two EObjects
(already loaded) and I would like to know if 1 is connected to another.
If I say

eObject1.eGet(reference).contains(eObject2) is loads the entire list of
connected eObjects. Really I want to say
eObject1.eGet(reference) -> get me all the ones you have without going
to the DB -> contains(eObject2).

Is this possible?

cheers,
ian
Re: [Teneo] Resolving lists [message #84815 is a reply to message #84785] Thu, 24 May 2007 20:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Ian,

Maybe you could do
((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
which should do a contains test without resolving proxies and that might
avoid Teneo resolving anything...


Ian Bull wrote:
> Is there a way to tell Teneo not to resolve a list? I have two
> EObjects (already loaded) and I would like to know if 1 is connected
> to another. If I say
>
> eObject1.eGet(reference).contains(eObject2) is loads the entire list
> of connected eObjects. Really I want to say
> eObject1.eGet(reference) -> get me all the ones you have without going
> to the DB -> contains(eObject2).
>
> Is this possible?
>
> cheers,
> ian
Re: [Teneo] Resolving lists [message #84830 is a reply to message #84815] Fri, 25 May 2007 04:10 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ian, Ed,
Even basicList will do a load(). Teneo (Hibernate/jpox) does not know that the two objects belong
together until the eObject1.reference list is loaded. A persistable list currently either has all
its content loaded or nothing loaded. Hibernate has a 'very lazy' list concept which supports
certain operations without loading but that is not yet supported by Teneo.

Teneo automatically replaces all EList instances with a PersistableEList, this class offers an
isLoaded method to check if a collection has already been loaded.
So for now the approach can be: you can check if the eGet returns a PersistableEList, if not you can
do contains on the list, if yes (is a PersistableEList) then you can check if it is loaded, if not
then you do a hql/jdoql query to check the relation, if yes then you do contains on the
persistableelist.
This logic can be made generic by using efeature names when creating a Hql query, You can check the
innerclass HbDataStore.ReferenceTo which does something similar.

gr. Martin

Ed Merks wrote:
> Ian,
>
> Maybe you could do
> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
> which should do a contains test without resolving proxies and that might
> avoid Teneo resolving anything...
>
>
> Ian Bull wrote:
>> Is there a way to tell Teneo not to resolve a list? I have two
>> EObjects (already loaded) and I would like to know if 1 is connected
>> to another. If I say
>>
>> eObject1.eGet(reference).contains(eObject2) is loads the entire list
>> of connected eObjects. Really I want to say
>> eObject1.eGet(reference) -> get me all the ones you have without going
>> to the DB -> contains(eObject2).
>>
>> Is this possible?
>>
>> cheers,
>> ian


--

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] Resolving lists [message #84844 is a reply to message #84830] Fri, 25 May 2007 04:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

I don't know if this is proper, but I got it working by using the following:

Object refs = A.eGet(reference);
PersistentList list = (PersistentList) ((HibernatePersistableEList)
refs).getDelegate();
Object obj = list.getStoredSnapshot();

The stored snapshot seems to contain the list of currently loaded
references, so if A and B are loaded, and A is connected to B, then B
will be in this list.

cheers,
ian


Martin Taal wrote:
> Ian, Ed,
> Even basicList will do a load(). Teneo (Hibernate/jpox) does not know
> that the two objects belong together until the eObject1.reference list
> is loaded. A persistable list currently either has all its content
> loaded or nothing loaded. Hibernate has a 'very lazy' list concept which
> supports certain operations without loading but that is not yet
> supported by Teneo.
>
> Teneo automatically replaces all EList instances with a
> PersistableEList, this class offers an isLoaded method to check if a
> collection has already been loaded.
> So for now the approach can be: you can check if the eGet returns a
> PersistableEList, if not you can do contains on the list, if yes (is a
> PersistableEList) then you can check if it is loaded, if not then you do
> a hql/jdoql query to check the relation, if yes then you do contains on
> the persistableelist.
> This logic can be made generic by using efeature names when creating a
> Hql query, You can check the innerclass HbDataStore.ReferenceTo which
> does something similar.
>
> gr. Martin
>
> Ed Merks wrote:
>> Ian,
>>
>> Maybe you could do
>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>> which should do a contains test without resolving proxies and that
>> might avoid Teneo resolving anything...
>>
>>
>> Ian Bull wrote:
>>> Is there a way to tell Teneo not to resolve a list? I have two
>>> EObjects (already loaded) and I would like to know if 1 is connected
>>> to another. If I say
>>>
>>> eObject1.eGet(reference).contains(eObject2) is loads the entire list
>>> of connected eObjects. Really I want to say
>>> eObject1.eGet(reference) -> get me all the ones you have without
>>> going to the DB -> contains(eObject2).
>>>
>>> Is this possible?
>>>
>>> cheers,
>>> ian
>
>
Re: [Teneo] Resolving lists [message #84874 is a reply to message #84844] Fri, 25 May 2007 04:37 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I am not sure if it will work always, afaiu the snapshot is used by hibernate to detect dirty state
of the collection. So it contains the state at the start of the transaction.
For my curiosity, how does B even get into the collection of A?

gr. Martin

Ian Bull wrote:
> I don't know if this is proper, but I got it working by using the
> following:
>
> Object refs = A.eGet(reference);
> PersistentList list = (PersistentList) ((HibernatePersistableEList)
> refs).getDelegate();
> Object obj = list.getStoredSnapshot();
>
> The stored snapshot seems to contain the list of currently loaded
> references, so if A and B are loaded, and A is connected to B, then B
> will be in this list.
>
> cheers,
> ian
>
>
> Martin Taal wrote:
>> Ian, Ed,
>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not know
>> that the two objects belong together until the eObject1.reference list
>> is loaded. A persistable list currently either has all its content
>> loaded or nothing loaded. Hibernate has a 'very lazy' list concept
>> which supports certain operations without loading but that is not yet
>> supported by Teneo.
>>
>> Teneo automatically replaces all EList instances with a
>> PersistableEList, this class offers an isLoaded method to check if a
>> collection has already been loaded.
>> So for now the approach can be: you can check if the eGet returns a
>> PersistableEList, if not you can do contains on the list, if yes (is a
>> PersistableEList) then you can check if it is loaded, if not then you
>> do a hql/jdoql query to check the relation, if yes then you do
>> contains on the persistableelist.
>> This logic can be made generic by using efeature names when creating a
>> Hql query, You can check the innerclass HbDataStore.ReferenceTo which
>> does something similar.
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>> Ian,
>>>
>>> Maybe you could do
>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>> which should do a contains test without resolving proxies and that
>>> might avoid Teneo resolving anything...
>>>
>>>
>>> Ian Bull wrote:
>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>> EObjects (already loaded) and I would like to know if 1 is connected
>>>> to another. If I say
>>>>
>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire list
>>>> of connected eObjects. Really I want to say
>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>> going to the DB -> contains(eObject2).
>>>>
>>>> Is this possible?
>>>>
>>>> cheers,
>>>> ian
>>
>>


--

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] Resolving lists [message #84889 is a reply to message #84874] Fri, 25 May 2007 05:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

I actually have a separate Lucene index of all my EObjects. So when I
do a query it is actually a lucene query. I have stored the UID and
table for each EObject in the lucene index file. So when the query
comes back, i get the table and UID (actually I get the MetaModel,
Database, Table, and UID).
1) I load the MetaModel
2) I load the Database
3) I select the Objects that match the UIDs from their table.

Now I have A and B, and I want to see if they are connected.

I am working on a general visualization tool for ECore. So ideally, I
can plug any ecore model (and instance data) into the tool to create
some views. Currently I am trying my work on a number of datasets and I
find Teneo a great way to persist a whole bunch of models/data.

cheers,
ian


Martin Taal wrote:
> I am not sure if it will work always, afaiu the snapshot is used by
> hibernate to detect dirty state of the collection. So it contains the
> state at the start of the transaction.
> For my curiosity, how does B even get into the collection of A?
>
> gr. Martin
>
> Ian Bull wrote:
>> I don't know if this is proper, but I got it working by using the
>> following:
>>
>> Object refs = A.eGet(reference);
>> PersistentList list = (PersistentList) ((HibernatePersistableEList)
>> refs).getDelegate();
>> Object obj = list.getStoredSnapshot();
>>
>> The stored snapshot seems to contain the list of currently loaded
>> references, so if A and B are loaded, and A is connected to B, then B
>> will be in this list.
>>
>> cheers,
>> ian
>>
>>
>> Martin Taal wrote:
>>> Ian, Ed,
>>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not know
>>> that the two objects belong together until the eObject1.reference
>>> list is loaded. A persistable list currently either has all its
>>> content loaded or nothing loaded. Hibernate has a 'very lazy' list
>>> concept which supports certain operations without loading but that is
>>> not yet supported by Teneo.
>>>
>>> Teneo automatically replaces all EList instances with a
>>> PersistableEList, this class offers an isLoaded method to check if a
>>> collection has already been loaded.
>>> So for now the approach can be: you can check if the eGet returns a
>>> PersistableEList, if not you can do contains on the list, if yes (is
>>> a PersistableEList) then you can check if it is loaded, if not then
>>> you do a hql/jdoql query to check the relation, if yes then you do
>>> contains on the persistableelist.
>>> This logic can be made generic by using efeature names when creating
>>> a Hql query, You can check the innerclass HbDataStore.ReferenceTo
>>> which does something similar.
>>>
>>> gr. Martin
>>>
>>> Ed Merks wrote:
>>>> Ian,
>>>>
>>>> Maybe you could do
>>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>>> which should do a contains test without resolving proxies and that
>>>> might avoid Teneo resolving anything...
>>>>
>>>>
>>>> Ian Bull wrote:
>>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>>> EObjects (already loaded) and I would like to know if 1 is
>>>>> connected to another. If I say
>>>>>
>>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire
>>>>> list of connected eObjects. Really I want to say
>>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>>> going to the DB -> contains(eObject2).
>>>>>
>>>>> Is this possible?
>>>>>
>>>>> cheers,
>>>>> ian
>>>
>>>
>
>
Re: [Teneo] Resolving lists [message #84904 is a reply to message #84889] Fri, 25 May 2007 06:15 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Interesting, some more questions from my side, how do you select the objects from the their table?
With table do you mean the eclass name?

gr. Martin

Ian Bull wrote:
> I actually have a separate Lucene index of all my EObjects. So when I
> do a query it is actually a lucene query. I have stored the UID and
> table for each EObject in the lucene index file. So when the query
> comes back, i get the table and UID (actually I get the MetaModel,
> Database, Table, and UID).
> 1) I load the MetaModel
> 2) I load the Database
> 3) I select the Objects that match the UIDs from their table.
>
> Now I have A and B, and I want to see if they are connected.
>
> I am working on a general visualization tool for ECore. So ideally, I
> can plug any ecore model (and instance data) into the tool to create
> some views. Currently I am trying my work on a number of datasets and I
> find Teneo a great way to persist a whole bunch of models/data.
>
> cheers,
> ian
>
>
> Martin Taal wrote:
>> I am not sure if it will work always, afaiu the snapshot is used by
>> hibernate to detect dirty state of the collection. So it contains the
>> state at the start of the transaction.
>> For my curiosity, how does B even get into the collection of A?
>>
>> gr. Martin
>>
>> Ian Bull wrote:
>>> I don't know if this is proper, but I got it working by using the
>>> following:
>>>
>>> Object refs = A.eGet(reference);
>>> PersistentList list = (PersistentList) ((HibernatePersistableEList)
>>> refs).getDelegate();
>>> Object obj = list.getStoredSnapshot();
>>>
>>> The stored snapshot seems to contain the list of currently loaded
>>> references, so if A and B are loaded, and A is connected to B, then B
>>> will be in this list.
>>>
>>> cheers,
>>> ian
>>>
>>>
>>> Martin Taal wrote:
>>>> Ian, Ed,
>>>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not
>>>> know that the two objects belong together until the
>>>> eObject1.reference list is loaded. A persistable list currently
>>>> either has all its content loaded or nothing loaded. Hibernate has a
>>>> 'very lazy' list concept which supports certain operations without
>>>> loading but that is not yet supported by Teneo.
>>>>
>>>> Teneo automatically replaces all EList instances with a
>>>> PersistableEList, this class offers an isLoaded method to check if a
>>>> collection has already been loaded.
>>>> So for now the approach can be: you can check if the eGet returns a
>>>> PersistableEList, if not you can do contains on the list, if yes (is
>>>> a PersistableEList) then you can check if it is loaded, if not then
>>>> you do a hql/jdoql query to check the relation, if yes then you do
>>>> contains on the persistableelist.
>>>> This logic can be made generic by using efeature names when creating
>>>> a Hql query, You can check the innerclass HbDataStore.ReferenceTo
>>>> which does something similar.
>>>>
>>>> gr. Martin
>>>>
>>>> Ed Merks wrote:
>>>>> Ian,
>>>>>
>>>>> Maybe you could do
>>>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>>>> which should do a contains test without resolving proxies and that
>>>>> might avoid Teneo resolving anything...
>>>>>
>>>>>
>>>>> Ian Bull wrote:
>>>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>>>> EObjects (already loaded) and I would like to know if 1 is
>>>>>> connected to another. If I say
>>>>>>
>>>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire
>>>>>> list of connected eObjects. Really I want to say
>>>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>>>> going to the DB -> contains(eObject2).
>>>>>>
>>>>>> Is this possible?
>>>>>>
>>>>>> cheers,
>>>>>> ian
>>>>
>>>>
>>
>>


--

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] Resolving lists [message #85028 is a reply to message #84904] Fri, 25 May 2007 16:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

Yep, I am using the eclass name for the table name, and the auto
generated UID that Teneo gives every row. Then I use the following query
to get the EObjects back:

"from " + "classifier " + "where e_id = " + e_idResult

I do this for the results from my lucene query. This gives me back all
the EObjects that match my query.

Does this make sense? I am completely off my nut?

Cheers,
Ian

Martin Taal wrote:
> Interesting, some more questions from my side, how do you select the
> objects from the their table? With table do you mean the eclass name?
>
> gr. Martin
>
> Ian Bull wrote:
>> I actually have a separate Lucene index of all my EObjects. So when I
>> do a query it is actually a lucene query. I have stored the UID and
>> table for each EObject in the lucene index file. So when the query
>> comes back, i get the table and UID (actually I get the MetaModel,
>> Database, Table, and UID).
>> 1) I load the MetaModel
>> 2) I load the Database
>> 3) I select the Objects that match the UIDs from their table.
>>
>> Now I have A and B, and I want to see if they are connected.
>>
>> I am working on a general visualization tool for ECore. So ideally, I
>> can plug any ecore model (and instance data) into the tool to create
>> some views. Currently I am trying my work on a number of datasets and
>> I find Teneo a great way to persist a whole bunch of models/data.
>>
>> cheers,
>> ian
>>
>>
>> Martin Taal wrote:
>>> I am not sure if it will work always, afaiu the snapshot is used by
>>> hibernate to detect dirty state of the collection. So it contains the
>>> state at the start of the transaction.
>>> For my curiosity, how does B even get into the collection of A?
>>>
>>> gr. Martin
>>>
>>> Ian Bull wrote:
>>>> I don't know if this is proper, but I got it working by using the
>>>> following:
>>>>
>>>> Object refs = A.eGet(reference);
>>>> PersistentList list = (PersistentList) ((HibernatePersistableEList)
>>>> refs).getDelegate();
>>>> Object obj = list.getStoredSnapshot();
>>>>
>>>> The stored snapshot seems to contain the list of currently loaded
>>>> references, so if A and B are loaded, and A is connected to B, then
>>>> B will be in this list.
>>>>
>>>> cheers,
>>>> ian
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Ian, Ed,
>>>>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not
>>>>> know that the two objects belong together until the
>>>>> eObject1.reference list is loaded. A persistable list currently
>>>>> either has all its content loaded or nothing loaded. Hibernate has
>>>>> a 'very lazy' list concept which supports certain operations
>>>>> without loading but that is not yet supported by Teneo.
>>>>>
>>>>> Teneo automatically replaces all EList instances with a
>>>>> PersistableEList, this class offers an isLoaded method to check if
>>>>> a collection has already been loaded.
>>>>> So for now the approach can be: you can check if the eGet returns a
>>>>> PersistableEList, if not you can do contains on the list, if yes
>>>>> (is a PersistableEList) then you can check if it is loaded, if not
>>>>> then you do a hql/jdoql query to check the relation, if yes then
>>>>> you do contains on the persistableelist.
>>>>> This logic can be made generic by using efeature names when
>>>>> creating a Hql query, You can check the innerclass
>>>>> HbDataStore.ReferenceTo which does something similar.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Ed Merks wrote:
>>>>>> Ian,
>>>>>>
>>>>>> Maybe you could do
>>>>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>>>>> which should do a contains test without resolving proxies and that
>>>>>> might avoid Teneo resolving anything...
>>>>>>
>>>>>>
>>>>>> Ian Bull wrote:
>>>>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>>>>> EObjects (already loaded) and I would like to know if 1 is
>>>>>>> connected to another. If I say
>>>>>>>
>>>>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire
>>>>>>> list of connected eObjects. Really I want to say
>>>>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>>>>> going to the DB -> contains(eObject2).
>>>>>>>
>>>>>>> Is this possible?
>>>>>>>
>>>>>>> cheers,
>>>>>>> ian
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] Resolving lists [message #85151 is a reply to message #84874] Sat, 26 May 2007 06:02 Go to previous message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

You're right Martin, It doesn't always work :(

I will try to create some creative HQL queries to solve this problem.

cheers,
ian

Martin Taal wrote:
> I am not sure if it will work always, afaiu the snapshot is used by
> hibernate to detect dirty state of the collection. So it contains the
> state at the start of the transaction.
> For my curiosity, how does B even get into the collection of A?
>
> gr. Martin
>
> Ian Bull wrote:
>> I don't know if this is proper, but I got it working by using the
>> following:
>>
>> Object refs = A.eGet(reference);
>> PersistentList list = (PersistentList) ((HibernatePersistableEList)
>> refs).getDelegate();
>> Object obj = list.getStoredSnapshot();
>>
>> The stored snapshot seems to contain the list of currently loaded
>> references, so if A and B are loaded, and A is connected to B, then B
>> will be in this list.
>>
>> cheers,
>> ian
>>
>>
>> Martin Taal wrote:
>>> Ian, Ed,
>>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not know
>>> that the two objects belong together until the eObject1.reference
>>> list is loaded. A persistable list currently either has all its
>>> content loaded or nothing loaded. Hibernate has a 'very lazy' list
>>> concept which supports certain operations without loading but that is
>>> not yet supported by Teneo.
>>>
>>> Teneo automatically replaces all EList instances with a
>>> PersistableEList, this class offers an isLoaded method to check if a
>>> collection has already been loaded.
>>> So for now the approach can be: you can check if the eGet returns a
>>> PersistableEList, if not you can do contains on the list, if yes (is
>>> a PersistableEList) then you can check if it is loaded, if not then
>>> you do a hql/jdoql query to check the relation, if yes then you do
>>> contains on the persistableelist.
>>> This logic can be made generic by using efeature names when creating
>>> a Hql query, You can check the innerclass HbDataStore.ReferenceTo
>>> which does something similar.
>>>
>>> gr. Martin
>>>
>>> Ed Merks wrote:
>>>> Ian,
>>>>
>>>> Maybe you could do
>>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>>> which should do a contains test without resolving proxies and that
>>>> might avoid Teneo resolving anything...
>>>>
>>>>
>>>> Ian Bull wrote:
>>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>>> EObjects (already loaded) and I would like to know if 1 is
>>>>> connected to another. If I say
>>>>>
>>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire
>>>>> list of connected eObjects. Really I want to say
>>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>>> going to the DB -> contains(eObject2).
>>>>>
>>>>> Is this possible?
>>>>>
>>>>> cheers,
>>>>> ian
>>>
>>>
>
>
Re: [Teneo] Resolving lists [message #606784 is a reply to message #84785] Thu, 24 May 2007 20:51 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Ian,

Maybe you could do
((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
which should do a contains test without resolving proxies and that might
avoid Teneo resolving anything...


Ian Bull wrote:
> Is there a way to tell Teneo not to resolve a list? I have two
> EObjects (already loaded) and I would like to know if 1 is connected
> to another. If I say
>
> eObject1.eGet(reference).contains(eObject2) is loads the entire list
> of connected eObjects. Really I want to say
> eObject1.eGet(reference) -> get me all the ones you have without going
> to the DB -> contains(eObject2).
>
> Is this possible?
>
> cheers,
> ian


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Teneo] Resolving lists [message #606785 is a reply to message #84815] Fri, 25 May 2007 04:10 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ian, Ed,
Even basicList will do a load(). Teneo (Hibernate/jpox) does not know that the two objects belong
together until the eObject1.reference list is loaded. A persistable list currently either has all
its content loaded or nothing loaded. Hibernate has a 'very lazy' list concept which supports
certain operations without loading but that is not yet supported by Teneo.

Teneo automatically replaces all EList instances with a PersistableEList, this class offers an
isLoaded method to check if a collection has already been loaded.
So for now the approach can be: you can check if the eGet returns a PersistableEList, if not you can
do contains on the list, if yes (is a PersistableEList) then you can check if it is loaded, if not
then you do a hql/jdoql query to check the relation, if yes then you do contains on the
persistableelist.
This logic can be made generic by using efeature names when creating a Hql query, You can check the
innerclass HbDataStore.ReferenceTo which does something similar.

gr. Martin

Ed Merks wrote:
> Ian,
>
> Maybe you could do
> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
> which should do a contains test without resolving proxies and that might
> avoid Teneo resolving anything...
>
>
> Ian Bull wrote:
>> Is there a way to tell Teneo not to resolve a list? I have two
>> EObjects (already loaded) and I would like to know if 1 is connected
>> to another. If I say
>>
>> eObject1.eGet(reference).contains(eObject2) is loads the entire list
>> of connected eObjects. Really I want to say
>> eObject1.eGet(reference) -> get me all the ones you have without going
>> to the DB -> contains(eObject2).
>>
>> Is this possible?
>>
>> cheers,
>> ian


--

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] Resolving lists [message #606786 is a reply to message #84830] Fri, 25 May 2007 04:22 Go to previous message
Ian Bull is currently offline Ian BullFriend
Messages: 145
Registered: July 2009
Senior Member
I don't know if this is proper, but I got it working by using the following:

Object refs = A.eGet(reference);
PersistentList list = (PersistentList) ((HibernatePersistableEList)
refs).getDelegate();
Object obj = list.getStoredSnapshot();

The stored snapshot seems to contain the list of currently loaded
references, so if A and B are loaded, and A is connected to B, then B
will be in this list.

cheers,
ian


Martin Taal wrote:
> Ian, Ed,
> Even basicList will do a load(). Teneo (Hibernate/jpox) does not know
> that the two objects belong together until the eObject1.reference list
> is loaded. A persistable list currently either has all its content
> loaded or nothing loaded. Hibernate has a 'very lazy' list concept which
> supports certain operations without loading but that is not yet
> supported by Teneo.
>
> Teneo automatically replaces all EList instances with a
> PersistableEList, this class offers an isLoaded method to check if a
> collection has already been loaded.
> So for now the approach can be: you can check if the eGet returns a
> PersistableEList, if not you can do contains on the list, if yes (is a
> PersistableEList) then you can check if it is loaded, if not then you do
> a hql/jdoql query to check the relation, if yes then you do contains on
> the persistableelist.
> This logic can be made generic by using efeature names when creating a
> Hql query, You can check the innerclass HbDataStore.ReferenceTo which
> does something similar.
>
> gr. Martin
>
> Ed Merks wrote:
>> Ian,
>>
>> Maybe you could do
>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>> which should do a contains test without resolving proxies and that
>> might avoid Teneo resolving anything...
>>
>>
>> Ian Bull wrote:
>>> Is there a way to tell Teneo not to resolve a list? I have two
>>> EObjects (already loaded) and I would like to know if 1 is connected
>>> to another. If I say
>>>
>>> eObject1.eGet(reference).contains(eObject2) is loads the entire list
>>> of connected eObjects. Really I want to say
>>> eObject1.eGet(reference) -> get me all the ones you have without
>>> going to the DB -> contains(eObject2).
>>>
>>> Is this possible?
>>>
>>> cheers,
>>> ian
>
>
Re: [Teneo] Resolving lists [message #606788 is a reply to message #84844] Fri, 25 May 2007 04:37 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I am not sure if it will work always, afaiu the snapshot is used by hibernate to detect dirty state
of the collection. So it contains the state at the start of the transaction.
For my curiosity, how does B even get into the collection of A?

gr. Martin

Ian Bull wrote:
> I don't know if this is proper, but I got it working by using the
> following:
>
> Object refs = A.eGet(reference);
> PersistentList list = (PersistentList) ((HibernatePersistableEList)
> refs).getDelegate();
> Object obj = list.getStoredSnapshot();
>
> The stored snapshot seems to contain the list of currently loaded
> references, so if A and B are loaded, and A is connected to B, then B
> will be in this list.
>
> cheers,
> ian
>
>
> Martin Taal wrote:
>> Ian, Ed,
>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not know
>> that the two objects belong together until the eObject1.reference list
>> is loaded. A persistable list currently either has all its content
>> loaded or nothing loaded. Hibernate has a 'very lazy' list concept
>> which supports certain operations without loading but that is not yet
>> supported by Teneo.
>>
>> Teneo automatically replaces all EList instances with a
>> PersistableEList, this class offers an isLoaded method to check if a
>> collection has already been loaded.
>> So for now the approach can be: you can check if the eGet returns a
>> PersistableEList, if not you can do contains on the list, if yes (is a
>> PersistableEList) then you can check if it is loaded, if not then you
>> do a hql/jdoql query to check the relation, if yes then you do
>> contains on the persistableelist.
>> This logic can be made generic by using efeature names when creating a
>> Hql query, You can check the innerclass HbDataStore.ReferenceTo which
>> does something similar.
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>> Ian,
>>>
>>> Maybe you could do
>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>> which should do a contains test without resolving proxies and that
>>> might avoid Teneo resolving anything...
>>>
>>>
>>> Ian Bull wrote:
>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>> EObjects (already loaded) and I would like to know if 1 is connected
>>>> to another. If I say
>>>>
>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire list
>>>> of connected eObjects. Really I want to say
>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>> going to the DB -> contains(eObject2).
>>>>
>>>> Is this possible?
>>>>
>>>> cheers,
>>>> ian
>>
>>


--

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] Resolving lists [message #606789 is a reply to message #84874] Fri, 25 May 2007 05:43 Go to previous message
Ian Bull is currently offline Ian BullFriend
Messages: 145
Registered: July 2009
Senior Member
I actually have a separate Lucene index of all my EObjects. So when I
do a query it is actually a lucene query. I have stored the UID and
table for each EObject in the lucene index file. So when the query
comes back, i get the table and UID (actually I get the MetaModel,
Database, Table, and UID).
1) I load the MetaModel
2) I load the Database
3) I select the Objects that match the UIDs from their table.

Now I have A and B, and I want to see if they are connected.

I am working on a general visualization tool for ECore. So ideally, I
can plug any ecore model (and instance data) into the tool to create
some views. Currently I am trying my work on a number of datasets and I
find Teneo a great way to persist a whole bunch of models/data.

cheers,
ian


Martin Taal wrote:
> I am not sure if it will work always, afaiu the snapshot is used by
> hibernate to detect dirty state of the collection. So it contains the
> state at the start of the transaction.
> For my curiosity, how does B even get into the collection of A?
>
> gr. Martin
>
> Ian Bull wrote:
>> I don't know if this is proper, but I got it working by using the
>> following:
>>
>> Object refs = A.eGet(reference);
>> PersistentList list = (PersistentList) ((HibernatePersistableEList)
>> refs).getDelegate();
>> Object obj = list.getStoredSnapshot();
>>
>> The stored snapshot seems to contain the list of currently loaded
>> references, so if A and B are loaded, and A is connected to B, then B
>> will be in this list.
>>
>> cheers,
>> ian
>>
>>
>> Martin Taal wrote:
>>> Ian, Ed,
>>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not know
>>> that the two objects belong together until the eObject1.reference
>>> list is loaded. A persistable list currently either has all its
>>> content loaded or nothing loaded. Hibernate has a 'very lazy' list
>>> concept which supports certain operations without loading but that is
>>> not yet supported by Teneo.
>>>
>>> Teneo automatically replaces all EList instances with a
>>> PersistableEList, this class offers an isLoaded method to check if a
>>> collection has already been loaded.
>>> So for now the approach can be: you can check if the eGet returns a
>>> PersistableEList, if not you can do contains on the list, if yes (is
>>> a PersistableEList) then you can check if it is loaded, if not then
>>> you do a hql/jdoql query to check the relation, if yes then you do
>>> contains on the persistableelist.
>>> This logic can be made generic by using efeature names when creating
>>> a Hql query, You can check the innerclass HbDataStore.ReferenceTo
>>> which does something similar.
>>>
>>> gr. Martin
>>>
>>> Ed Merks wrote:
>>>> Ian,
>>>>
>>>> Maybe you could do
>>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>>> which should do a contains test without resolving proxies and that
>>>> might avoid Teneo resolving anything...
>>>>
>>>>
>>>> Ian Bull wrote:
>>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>>> EObjects (already loaded) and I would like to know if 1 is
>>>>> connected to another. If I say
>>>>>
>>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire
>>>>> list of connected eObjects. Really I want to say
>>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>>> going to the DB -> contains(eObject2).
>>>>>
>>>>> Is this possible?
>>>>>
>>>>> cheers,
>>>>> ian
>>>
>>>
>
>
Re: [Teneo] Resolving lists [message #606790 is a reply to message #84889] Fri, 25 May 2007 06:15 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Interesting, some more questions from my side, how do you select the objects from the their table?
With table do you mean the eclass name?

gr. Martin

Ian Bull wrote:
> I actually have a separate Lucene index of all my EObjects. So when I
> do a query it is actually a lucene query. I have stored the UID and
> table for each EObject in the lucene index file. So when the query
> comes back, i get the table and UID (actually I get the MetaModel,
> Database, Table, and UID).
> 1) I load the MetaModel
> 2) I load the Database
> 3) I select the Objects that match the UIDs from their table.
>
> Now I have A and B, and I want to see if they are connected.
>
> I am working on a general visualization tool for ECore. So ideally, I
> can plug any ecore model (and instance data) into the tool to create
> some views. Currently I am trying my work on a number of datasets and I
> find Teneo a great way to persist a whole bunch of models/data.
>
> cheers,
> ian
>
>
> Martin Taal wrote:
>> I am not sure if it will work always, afaiu the snapshot is used by
>> hibernate to detect dirty state of the collection. So it contains the
>> state at the start of the transaction.
>> For my curiosity, how does B even get into the collection of A?
>>
>> gr. Martin
>>
>> Ian Bull wrote:
>>> I don't know if this is proper, but I got it working by using the
>>> following:
>>>
>>> Object refs = A.eGet(reference);
>>> PersistentList list = (PersistentList) ((HibernatePersistableEList)
>>> refs).getDelegate();
>>> Object obj = list.getStoredSnapshot();
>>>
>>> The stored snapshot seems to contain the list of currently loaded
>>> references, so if A and B are loaded, and A is connected to B, then B
>>> will be in this list.
>>>
>>> cheers,
>>> ian
>>>
>>>
>>> Martin Taal wrote:
>>>> Ian, Ed,
>>>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not
>>>> know that the two objects belong together until the
>>>> eObject1.reference list is loaded. A persistable list currently
>>>> either has all its content loaded or nothing loaded. Hibernate has a
>>>> 'very lazy' list concept which supports certain operations without
>>>> loading but that is not yet supported by Teneo.
>>>>
>>>> Teneo automatically replaces all EList instances with a
>>>> PersistableEList, this class offers an isLoaded method to check if a
>>>> collection has already been loaded.
>>>> So for now the approach can be: you can check if the eGet returns a
>>>> PersistableEList, if not you can do contains on the list, if yes (is
>>>> a PersistableEList) then you can check if it is loaded, if not then
>>>> you do a hql/jdoql query to check the relation, if yes then you do
>>>> contains on the persistableelist.
>>>> This logic can be made generic by using efeature names when creating
>>>> a Hql query, You can check the innerclass HbDataStore.ReferenceTo
>>>> which does something similar.
>>>>
>>>> gr. Martin
>>>>
>>>> Ed Merks wrote:
>>>>> Ian,
>>>>>
>>>>> Maybe you could do
>>>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>>>> which should do a contains test without resolving proxies and that
>>>>> might avoid Teneo resolving anything...
>>>>>
>>>>>
>>>>> Ian Bull wrote:
>>>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>>>> EObjects (already loaded) and I would like to know if 1 is
>>>>>> connected to another. If I say
>>>>>>
>>>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire
>>>>>> list of connected eObjects. Really I want to say
>>>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>>>> going to the DB -> contains(eObject2).
>>>>>>
>>>>>> Is this possible?
>>>>>>
>>>>>> cheers,
>>>>>> ian
>>>>
>>>>
>>
>>


--

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] Resolving lists [message #606798 is a reply to message #84904] Fri, 25 May 2007 16:50 Go to previous message
Ian Bull is currently offline Ian BullFriend
Messages: 145
Registered: July 2009
Senior Member
Yep, I am using the eclass name for the table name, and the auto
generated UID that Teneo gives every row. Then I use the following query
to get the EObjects back:

"from " + "classifier " + "where e_id = " + e_idResult

I do this for the results from my lucene query. This gives me back all
the EObjects that match my query.

Does this make sense? I am completely off my nut?

Cheers,
Ian

Martin Taal wrote:
> Interesting, some more questions from my side, how do you select the
> objects from the their table? With table do you mean the eclass name?
>
> gr. Martin
>
> Ian Bull wrote:
>> I actually have a separate Lucene index of all my EObjects. So when I
>> do a query it is actually a lucene query. I have stored the UID and
>> table for each EObject in the lucene index file. So when the query
>> comes back, i get the table and UID (actually I get the MetaModel,
>> Database, Table, and UID).
>> 1) I load the MetaModel
>> 2) I load the Database
>> 3) I select the Objects that match the UIDs from their table.
>>
>> Now I have A and B, and I want to see if they are connected.
>>
>> I am working on a general visualization tool for ECore. So ideally, I
>> can plug any ecore model (and instance data) into the tool to create
>> some views. Currently I am trying my work on a number of datasets and
>> I find Teneo a great way to persist a whole bunch of models/data.
>>
>> cheers,
>> ian
>>
>>
>> Martin Taal wrote:
>>> I am not sure if it will work always, afaiu the snapshot is used by
>>> hibernate to detect dirty state of the collection. So it contains the
>>> state at the start of the transaction.
>>> For my curiosity, how does B even get into the collection of A?
>>>
>>> gr. Martin
>>>
>>> Ian Bull wrote:
>>>> I don't know if this is proper, but I got it working by using the
>>>> following:
>>>>
>>>> Object refs = A.eGet(reference);
>>>> PersistentList list = (PersistentList) ((HibernatePersistableEList)
>>>> refs).getDelegate();
>>>> Object obj = list.getStoredSnapshot();
>>>>
>>>> The stored snapshot seems to contain the list of currently loaded
>>>> references, so if A and B are loaded, and A is connected to B, then
>>>> B will be in this list.
>>>>
>>>> cheers,
>>>> ian
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Ian, Ed,
>>>>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not
>>>>> know that the two objects belong together until the
>>>>> eObject1.reference list is loaded. A persistable list currently
>>>>> either has all its content loaded or nothing loaded. Hibernate has
>>>>> a 'very lazy' list concept which supports certain operations
>>>>> without loading but that is not yet supported by Teneo.
>>>>>
>>>>> Teneo automatically replaces all EList instances with a
>>>>> PersistableEList, this class offers an isLoaded method to check if
>>>>> a collection has already been loaded.
>>>>> So for now the approach can be: you can check if the eGet returns a
>>>>> PersistableEList, if not you can do contains on the list, if yes
>>>>> (is a PersistableEList) then you can check if it is loaded, if not
>>>>> then you do a hql/jdoql query to check the relation, if yes then
>>>>> you do contains on the persistableelist.
>>>>> This logic can be made generic by using efeature names when
>>>>> creating a Hql query, You can check the innerclass
>>>>> HbDataStore.ReferenceTo which does something similar.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Ed Merks wrote:
>>>>>> Ian,
>>>>>>
>>>>>> Maybe you could do
>>>>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>>>>> which should do a contains test without resolving proxies and that
>>>>>> might avoid Teneo resolving anything...
>>>>>>
>>>>>>
>>>>>> Ian Bull wrote:
>>>>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>>>>> EObjects (already loaded) and I would like to know if 1 is
>>>>>>> connected to another. If I say
>>>>>>>
>>>>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire
>>>>>>> list of connected eObjects. Really I want to say
>>>>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>>>>> going to the DB -> contains(eObject2).
>>>>>>>
>>>>>>> Is this possible?
>>>>>>>
>>>>>>> cheers,
>>>>>>> ian
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] Resolving lists [message #606806 is a reply to message #84874] Sat, 26 May 2007 06:02 Go to previous message
Ian Bull is currently offline Ian BullFriend
Messages: 145
Registered: July 2009
Senior Member
You're right Martin, It doesn't always work :(

I will try to create some creative HQL queries to solve this problem.

cheers,
ian

Martin Taal wrote:
> I am not sure if it will work always, afaiu the snapshot is used by
> hibernate to detect dirty state of the collection. So it contains the
> state at the start of the transaction.
> For my curiosity, how does B even get into the collection of A?
>
> gr. Martin
>
> Ian Bull wrote:
>> I don't know if this is proper, but I got it working by using the
>> following:
>>
>> Object refs = A.eGet(reference);
>> PersistentList list = (PersistentList) ((HibernatePersistableEList)
>> refs).getDelegate();
>> Object obj = list.getStoredSnapshot();
>>
>> The stored snapshot seems to contain the list of currently loaded
>> references, so if A and B are loaded, and A is connected to B, then B
>> will be in this list.
>>
>> cheers,
>> ian
>>
>>
>> Martin Taal wrote:
>>> Ian, Ed,
>>> Even basicList will do a load(). Teneo (Hibernate/jpox) does not know
>>> that the two objects belong together until the eObject1.reference
>>> list is loaded. A persistable list currently either has all its
>>> content loaded or nothing loaded. Hibernate has a 'very lazy' list
>>> concept which supports certain operations without loading but that is
>>> not yet supported by Teneo.
>>>
>>> Teneo automatically replaces all EList instances with a
>>> PersistableEList, this class offers an isLoaded method to check if a
>>> collection has already been loaded.
>>> So for now the approach can be: you can check if the eGet returns a
>>> PersistableEList, if not you can do contains on the list, if yes (is
>>> a PersistableEList) then you can check if it is loaded, if not then
>>> you do a hql/jdoql query to check the relation, if yes then you do
>>> contains on the persistableelist.
>>> This logic can be made generic by using efeature names when creating
>>> a Hql query, You can check the innerclass HbDataStore.ReferenceTo
>>> which does something similar.
>>>
>>> gr. Martin
>>>
>>> Ed Merks wrote:
>>>> Ian,
>>>>
>>>> Maybe you could do
>>>> ((InternalEList)eObject1.eGet(reference)).basicList().contai ns(eObject2)
>>>> which should do a contains test without resolving proxies and that
>>>> might avoid Teneo resolving anything...
>>>>
>>>>
>>>> Ian Bull wrote:
>>>>> Is there a way to tell Teneo not to resolve a list? I have two
>>>>> EObjects (already loaded) and I would like to know if 1 is
>>>>> connected to another. If I say
>>>>>
>>>>> eObject1.eGet(reference).contains(eObject2) is loads the entire
>>>>> list of connected eObjects. Really I want to say
>>>>> eObject1.eGet(reference) -> get me all the ones you have without
>>>>> going to the DB -> contains(eObject2).
>>>>>
>>>>> Is this possible?
>>>>>
>>>>> cheers,
>>>>> ian
>>>
>>>
>
>
Previous Topic:Re: [Teneo] new user questions
Next Topic:[Teneo]JUnit stackoverflow
Goto Forum:
  


Current Time: Thu Mar 28 16:16:32 GMT 2024

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

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

Back to the top