Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » Search for all references to a specific instance
Search for all references to a specific instance [message #116908] |
Fri, 04 April 2008 14:43  |
Eclipse User |
|
|
|
I'm using TENEO and hibernate on a very large model and complex
relationships (references).
I want to create a class that gives me all the parent instances that
reference one specific child instance.
For example:
Let assume I have an eCore model that represent a car. The engine (one
class) as a reference (association) to screw (common class) that is used
in the engine. The same for the transmission, AC and etc. That means
in the model the class instance "screw1" is referenced by many other
instances of the other classes.
If I have an instance of "screw1", I want to find out which instance
references this "screw1" (for example write a report if the screw
changes which component gets impacted - engine transmission and etc.).
Since my database is large, I disabled the Hibernate option to load all
top classes when a new resource is created.
I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
resourceSet), but it does not return any information.
How can I search the entire database to find all the references to a
single instance?
Thanks
Yigal
|
|
|
Re: Search for all references to a specific instance [message #116935 is a reply to message #116908] |
Fri, 04 April 2008 14:58   |
Eclipse User |
|
|
|
Hi Yigal,
The datastore has the getCrossReferencers method for that.
When the datastore is initialized it analyzes the internal datamodel and for each reference creates
the query required to get the refered-to. The getCrossReferencers method re-uses this information to
query the db.
Note that if the amount of referees can be very large then getCrossReferencers can still be
performance intensive.
A possible improvement can be that you also pass the maximum number of objects you want to receive
back. So that the search can be limited or stops earlier.
gr. Martin
Yigal wrote:
> I'm using TENEO and hibernate on a very large model and complex
> relationships (references).
> I want to create a class that gives me all the parent instances that
> reference one specific child instance.
> For example:
> Let assume I have an eCore model that represent a car. The engine (one
> class) as a reference (association) to screw (common class) that is used
> in the engine. The same for the transmission, AC and etc. That means
> in the model the class instance "screw1" is referenced by many other
> instances of the other classes.
> If I have an instance of "screw1", I want to find out which instance
> references this "screw1" (for example write a report if the screw
> changes which component gets impacted - engine transmission and etc.).
>
> Since my database is large, I disabled the Hibernate option to load all
> top classes when a new resource is created.
> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
> resourceSet), but it does not return any information.
>
> How can I search the entire database to find all the references to a
> single instance?
>
> Thanks
> Yigal
--
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: Search for all references to a specific instance [message #116948 is a reply to message #116935] |
Sat, 05 April 2008 19:14   |
Eclipse User |
|
|
|
Hi Martin,
This is the exact methid I'm looking for. Can you help with some sample
code?
I tried the following code:
// Get the data store from valid repository
HbDataStore dStore = myRepository.getDataStore ();
// Open a session
Session sc = ds.getSessionFactory().openSession();
// Get referencers
Object [] objs = ds.getCrossReferencers(sc, screw1);
When I run this I get ZERO items, regardless for number of references.
Any ideas?
Thanks
Yigal
Martin Taal wrote:
> Hi Yigal,
> The datastore has the getCrossReferencers method for that.
> When the datastore is initialized it analyzes the internal datamodel and
> for each reference creates the query required to get the refered-to. The
> getCrossReferencers method re-uses this information to query the db.
> Note that if the amount of referees can be very large then
> getCrossReferencers can still be performance intensive.
> A possible improvement can be that you also pass the maximum number of
> objects you want to receive back. So that the search can be limited or
> stops earlier.
>
> gr. Martin
>
> Yigal wrote:
>> I'm using TENEO and hibernate on a very large model and complex
>> relationships (references).
>> I want to create a class that gives me all the parent instances that
>> reference one specific child instance.
>> For example:
>> Let assume I have an eCore model that represent a car. The engine
>> (one class) as a reference (association) to screw (common class) that
>> is used in the engine. The same for the transmission, AC and etc.
>> That means in the model the class instance "screw1" is referenced by
>> many other instances of the other classes.
>> If I have an instance of "screw1", I want to find out which instance
>> references this "screw1" (for example write a report if the screw
>> changes which component gets impacted - engine transmission and etc.).
>>
>> Since my database is large, I disabled the Hibernate option to load
>> all top classes when a new resource is created.
>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>> resourceSet), but it does not return any information.
>>
>> How can I search the entire database to find all the references to a
>> single instance?
>>
>> Thanks
>> Yigal
>
>
|
|
|
Re: Search for all references to a specific instance [message #117000 is a reply to message #116948] |
Sun, 06 April 2008 06:08   |
Eclipse User |
|
|
|
Hi Yigal,
No special ideas, the way you use it is fine. I would debug into the getCrossReferencers method to
see what it does/why it does not work.
gr. Martin
Yigal wrote:
> Hi Martin,
> This is the exact methid I'm looking for. Can you help with some sample
> code?
> I tried the following code:
>
> // Get the data store from valid repository
> HbDataStore dStore = myRepository.getDataStore ();
> // Open a session
> Session sc = ds.getSessionFactory().openSession();
> // Get referencers
> Object [] objs = ds.getCrossReferencers(sc, screw1);
>
> When I run this I get ZERO items, regardless for number of references.
>
> Any ideas?
>
> Thanks
> Yigal
>
>
> Martin Taal wrote:
>> Hi Yigal,
>> The datastore has the getCrossReferencers method for that.
>> When the datastore is initialized it analyzes the internal datamodel
>> and for each reference creates the query required to get the
>> refered-to. The getCrossReferencers method re-uses this information to
>> query the db.
>> Note that if the amount of referees can be very large then
>> getCrossReferencers can still be performance intensive.
>> A possible improvement can be that you also pass the maximum number of
>> objects you want to receive back. So that the search can be limited or
>> stops earlier.
>>
>> gr. Martin
>>
>> Yigal wrote:
>>> I'm using TENEO and hibernate on a very large model and complex
>>> relationships (references).
>>> I want to create a class that gives me all the parent instances that
>>> reference one specific child instance.
>>> For example:
>>> Let assume I have an eCore model that represent a car. The engine
>>> (one class) as a reference (association) to screw (common class) that
>>> is used in the engine. The same for the transmission, AC and etc.
>>> That means in the model the class instance "screw1" is referenced by
>>> many other instances of the other classes.
>>> If I have an instance of "screw1", I want to find out which instance
>>> references this "screw1" (for example write a report if the screw
>>> changes which component gets impacted - engine transmission and etc.).
>>>
>>> Since my database is large, I disabled the Hibernate option to load
>>> all top classes when a new resource is created.
>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>> resourceSet), but it does not return any information.
>>>
>>> How can I search the entire database to find all the references to a
>>> single instance?
>>>
>>> Thanks
>>> Yigal
>>
>>
--
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: Search for all references to a specific instance [message #117012 is a reply to message #117000] |
Sun, 06 April 2008 09:34   |
Eclipse User |
|
|
|
Hi Martin,
Thanks for the advise, I debug the code and here is what I found:
My "screw" class extends the class called "Part". Since the engines has
different parts, I keep a reference list of "Parts" for the engine.
So when I run the getCrossReferencers, the method search for "Screw"
class, while the only reference list is a "Part". If I change the value
from screw to part the method returns the correct engine value.
DO you have any ideas how to call the getCrossReferencers with an object
but make it look make it look for the parent class as well?
Should I rewrite the method?
Thanks
Yigal
Martin Taal wrote:
> Hi Yigal,
> No special ideas, the way you use it is fine. I would debug into the
> getCrossReferencers method to see what it does/why it does not work.
>
> gr. Martin
>
> Yigal wrote:
>> Hi Martin,
>> This is the exact methid I'm looking for. Can you help with some
>> sample code?
>> I tried the following code:
>>
>> // Get the data store from valid repository
>> HbDataStore dStore = myRepository.getDataStore ();
>> // Open a session
>> Session sc = ds.getSessionFactory().openSession();
>> // Get referencers
>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>
>> When I run this I get ZERO items, regardless for number of references.
>>
>> Any ideas?
>>
>> Thanks
>> Yigal
>>
>>
>> Martin Taal wrote:
>>> Hi Yigal,
>>> The datastore has the getCrossReferencers method for that.
>>> When the datastore is initialized it analyzes the internal datamodel
>>> and for each reference creates the query required to get the
>>> refered-to. The getCrossReferencers method re-uses this information
>>> to query the db.
>>> Note that if the amount of referees can be very large then
>>> getCrossReferencers can still be performance intensive.
>>> A possible improvement can be that you also pass the maximum number
>>> of objects you want to receive back. So that the search can be
>>> limited or stops earlier.
>>>
>>> gr. Martin
>>>
>>> Yigal wrote:
>>>> I'm using TENEO and hibernate on a very large model and complex
>>>> relationships (references).
>>>> I want to create a class that gives me all the parent instances that
>>>> reference one specific child instance.
>>>> For example:
>>>> Let assume I have an eCore model that represent a car. The engine
>>>> (one class) as a reference (association) to screw (common class)
>>>> that is used in the engine. The same for the transmission, AC and
>>>> etc. That means in the model the class instance "screw1" is
>>>> referenced by many other instances of the other classes.
>>>> If I have an instance of "screw1", I want to find out which instance
>>>> references this "screw1" (for example write a report if the screw
>>>> changes which component gets impacted - engine transmission and etc.).
>>>>
>>>> Since my database is large, I disabled the Hibernate option to load
>>>> all top classes when a new resource is created.
>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>> resourceSet), but it does not return any information.
>>>>
>>>> How can I search the entire database to find all the references to a
>>>> single instance?
>>>>
>>>> Thanks
>>>> Yigal
>>>
>>>
>
>
|
|
|
Re: Search for all references to a specific instance [message #117026 is a reply to message #117012] |
Sun, 06 April 2008 10:12   |
Eclipse User |
|
|
|
Hi Yigal,
This should work fine for the subclass also. The computeReferers ends up in the setRefersToOfSupers
method, this method should copy all found references from the parent class to subclass. Can you
check/debug why it does not do that for the subclass?
gr. Martin
Yigal wrote:
> Hi Martin,
> Thanks for the advise, I debug the code and here is what I found:
> My "screw" class extends the class called "Part". Since the engines has
> different parts, I keep a reference list of "Parts" for the engine.
>
> So when I run the getCrossReferencers, the method search for "Screw"
> class, while the only reference list is a "Part". If I change the value
> from screw to part the method returns the correct engine value.
>
> DO you have any ideas how to call the getCrossReferencers with an object
> but make it look make it look for the parent class as well?
> Should I rewrite the method?
>
> Thanks
> Yigal
>
>
> Martin Taal wrote:
>> Hi Yigal,
>> No special ideas, the way you use it is fine. I would debug into the
>> getCrossReferencers method to see what it does/why it does not work.
>>
>> gr. Martin
>>
>> Yigal wrote:
>>> Hi Martin,
>>> This is the exact methid I'm looking for. Can you help with some
>>> sample code?
>>> I tried the following code:
>>>
>>> // Get the data store from valid repository
>>> HbDataStore dStore = myRepository.getDataStore ();
>>> // Open a session
>>> Session sc = ds.getSessionFactory().openSession();
>>> // Get referencers
>>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>>
>>> When I run this I get ZERO items, regardless for number of references.
>>>
>>> Any ideas?
>>>
>>> Thanks
>>> Yigal
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Yigal,
>>>> The datastore has the getCrossReferencers method for that.
>>>> When the datastore is initialized it analyzes the internal datamodel
>>>> and for each reference creates the query required to get the
>>>> refered-to. The getCrossReferencers method re-uses this information
>>>> to query the db.
>>>> Note that if the amount of referees can be very large then
>>>> getCrossReferencers can still be performance intensive.
>>>> A possible improvement can be that you also pass the maximum number
>>>> of objects you want to receive back. So that the search can be
>>>> limited or stops earlier.
>>>>
>>>> gr. Martin
>>>>
>>>> Yigal wrote:
>>>>> I'm using TENEO and hibernate on a very large model and complex
>>>>> relationships (references).
>>>>> I want to create a class that gives me all the parent instances
>>>>> that reference one specific child instance.
>>>>> For example:
>>>>> Let assume I have an eCore model that represent a car. The engine
>>>>> (one class) as a reference (association) to screw (common class)
>>>>> that is used in the engine. The same for the transmission, AC and
>>>>> etc. That means in the model the class instance "screw1" is
>>>>> referenced by many other instances of the other classes.
>>>>> If I have an instance of "screw1", I want to find out which
>>>>> instance references this "screw1" (for example write a report if
>>>>> the screw changes which component gets impacted - engine
>>>>> transmission and etc.).
>>>>>
>>>>> Since my database is large, I disabled the Hibernate option to load
>>>>> all top classes when a new resource is created.
>>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>>> resourceSet), but it does not return any information.
>>>>>
>>>>> How can I search the entire database to find all the references to
>>>>> a single instance?
>>>>>
>>>>> Thanks
>>>>> Yigal
>>>>
>>>>
>>
>>
--
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: Search for all references to a specific instance [message #117431 is a reply to message #117026] |
Wed, 09 April 2008 11:46   |
Eclipse User |
|
|
|
Hi Martin,
I Debug through the initialization code in the HbDataStore class.
When it builds the refers to supper class list, there is an issue with
the code:
(on line 932) the code is:
if (classDone.contains(eclass)) {
return refersTo.get(eclass);
}
In my case, the "screw" as a supper that is a "Part". The "Part" was
already in the list of classDone so the classDone.contains returns true.
However the refertTo does not have it so it returns a NULL and therefore
the method addUnique fails becuase the list is empty. (l2 == null);
It seems to me the code needs to validate that the class is in refersTo
and not just in classDone.
Yigal
Martin Taal wrote:
> Hi Yigal,
> This should work fine for the subclass also. The computeReferers ends up
> in the setRefersToOfSupers method, this method should copy all found
> references from the parent class to subclass. Can you check/debug why it
> does not do that for the subclass?
>
> gr. Martin
>
> Yigal wrote:
>> Hi Martin,
>> Thanks for the advise, I debug the code and here is what I found:
>> My "screw" class extends the class called "Part". Since the engines
>> has different parts, I keep a reference list of "Parts" for the engine.
>>
>> So when I run the getCrossReferencers, the method search for "Screw"
>> class, while the only reference list is a "Part". If I change the
>> value from screw to part the method returns the correct engine value.
>>
>> DO you have any ideas how to call the getCrossReferencers with an
>> object but make it look make it look for the parent class as well?
>> Should I rewrite the method?
>>
>> Thanks
>> Yigal
>>
>>
>> Martin Taal wrote:
>>> Hi Yigal,
>>> No special ideas, the way you use it is fine. I would debug into the
>>> getCrossReferencers method to see what it does/why it does not work.
>>>
>>> gr. Martin
>>>
>>> Yigal wrote:
>>>> Hi Martin,
>>>> This is the exact methid I'm looking for. Can you help with some
>>>> sample code?
>>>> I tried the following code:
>>>>
>>>> // Get the data store from valid repository
>>>> HbDataStore dStore = myRepository.getDataStore ();
>>>> // Open a session
>>>> Session sc = ds.getSessionFactory().openSession();
>>>> // Get referencers
>>>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>>>
>>>> When I run this I get ZERO items, regardless for number of references.
>>>>
>>>> Any ideas?
>>>>
>>>> Thanks
>>>> Yigal
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Hi Yigal,
>>>>> The datastore has the getCrossReferencers method for that.
>>>>> When the datastore is initialized it analyzes the internal
>>>>> datamodel and for each reference creates the query required to get
>>>>> the refered-to. The getCrossReferencers method re-uses this
>>>>> information to query the db.
>>>>> Note that if the amount of referees can be very large then
>>>>> getCrossReferencers can still be performance intensive.
>>>>> A possible improvement can be that you also pass the maximum number
>>>>> of objects you want to receive back. So that the search can be
>>>>> limited or stops earlier.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Yigal wrote:
>>>>>> I'm using TENEO and hibernate on a very large model and complex
>>>>>> relationships (references).
>>>>>> I want to create a class that gives me all the parent instances
>>>>>> that reference one specific child instance.
>>>>>> For example:
>>>>>> Let assume I have an eCore model that represent a car. The engine
>>>>>> (one class) as a reference (association) to screw (common class)
>>>>>> that is used in the engine. The same for the transmission, AC and
>>>>>> etc. That means in the model the class instance "screw1" is
>>>>>> referenced by many other instances of the other classes.
>>>>>> If I have an instance of "screw1", I want to find out which
>>>>>> instance references this "screw1" (for example write a report if
>>>>>> the screw changes which component gets impacted - engine
>>>>>> transmission and etc.).
>>>>>>
>>>>>> Since my database is large, I disabled the Hibernate option to
>>>>>> load all top classes when a new resource is created.
>>>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>>>> resourceSet), but it does not return any information.
>>>>>>
>>>>>> How can I search the entire database to find all the references to
>>>>>> a single instance?
>>>>>>
>>>>>> Thanks
>>>>>> Yigal
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: Search for all references to a specific instance [message #117458 is a reply to message #117431] |
Wed, 09 April 2008 12:07   |
Eclipse User |
|
|
|
Martin,
Looking at other section of the code it seems to me that the code should be:
(on line 932) the code is:
if (classDone.contains(eclass)) {
return refersTo.get(ens.toEntityName(eclass));
}
Yigal
Yigal wrote:
> Hi Martin,
> I Debug through the initialization code in the HbDataStore class.
> When it builds the refers to supper class list, there is an issue with
> the code:
>
> (on line 932) the code is:
> if (classDone.contains(eclass)) {
> return refersTo.get(eclass);
> }
> In my case, the "screw" as a supper that is a "Part". The "Part" was
> already in the list of classDone so the classDone.contains returns true.
> However the refertTo does not have it so it returns a NULL and therefore
> the method addUnique fails becuase the list is empty. (l2 == null);
>
> It seems to me the code needs to validate that the class is in refersTo
> and not just in classDone.
>
> Yigal
>
>
>
> Martin Taal wrote:
>> Hi Yigal,
>> This should work fine for the subclass also. The computeReferers ends
>> up in the setRefersToOfSupers method, this method should copy all
>> found references from the parent class to subclass. Can you
>> check/debug why it does not do that for the subclass?
>>
>> gr. Martin
>>
>> Yigal wrote:
>>> Hi Martin,
>>> Thanks for the advise, I debug the code and here is what I found:
>>> My "screw" class extends the class called "Part". Since the engines
>>> has different parts, I keep a reference list of "Parts" for the engine.
>>>
>>> So when I run the getCrossReferencers, the method search for "Screw"
>>> class, while the only reference list is a "Part". If I change the
>>> value from screw to part the method returns the correct engine value.
>>>
>>> DO you have any ideas how to call the getCrossReferencers with an
>>> object but make it look make it look for the parent class as well?
>>> Should I rewrite the method?
>>>
>>> Thanks
>>> Yigal
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Yigal,
>>>> No special ideas, the way you use it is fine. I would debug into the
>>>> getCrossReferencers method to see what it does/why it does not work.
>>>>
>>>> gr. Martin
>>>>
>>>> Yigal wrote:
>>>>> Hi Martin,
>>>>> This is the exact methid I'm looking for. Can you help with some
>>>>> sample code?
>>>>> I tried the following code:
>>>>>
>>>>> // Get the data store from valid repository
>>>>> HbDataStore dStore = myRepository.getDataStore ();
>>>>> // Open a session
>>>>> Session sc = ds.getSessionFactory().openSession();
>>>>> // Get referencers
>>>>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>>>>
>>>>> When I run this I get ZERO items, regardless for number of references.
>>>>>
>>>>> Any ideas?
>>>>>
>>>>> Thanks
>>>>> Yigal
>>>>>
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi Yigal,
>>>>>> The datastore has the getCrossReferencers method for that.
>>>>>> When the datastore is initialized it analyzes the internal
>>>>>> datamodel and for each reference creates the query required to get
>>>>>> the refered-to. The getCrossReferencers method re-uses this
>>>>>> information to query the db.
>>>>>> Note that if the amount of referees can be very large then
>>>>>> getCrossReferencers can still be performance intensive.
>>>>>> A possible improvement can be that you also pass the maximum
>>>>>> number of objects you want to receive back. So that the search can
>>>>>> be limited or stops earlier.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Yigal wrote:
>>>>>>> I'm using TENEO and hibernate on a very large model and complex
>>>>>>> relationships (references).
>>>>>>> I want to create a class that gives me all the parent instances
>>>>>>> that reference one specific child instance.
>>>>>>> For example:
>>>>>>> Let assume I have an eCore model that represent a car. The
>>>>>>> engine (one class) as a reference (association) to screw (common
>>>>>>> class) that is used in the engine. The same for the
>>>>>>> transmission, AC and etc. That means in the model the class
>>>>>>> instance "screw1" is referenced by many other instances of the
>>>>>>> other classes.
>>>>>>> If I have an instance of "screw1", I want to find out which
>>>>>>> instance references this "screw1" (for example write a report if
>>>>>>> the screw changes which component gets impacted - engine
>>>>>>> transmission and etc.).
>>>>>>>
>>>>>>> Since my database is large, I disabled the Hibernate option to
>>>>>>> load all top classes when a new resource is created.
>>>>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>>>>> resourceSet), but it does not return any information.
>>>>>>>
>>>>>>> How can I search the entire database to find all the references
>>>>>>> to a single instance?
>>>>>>>
>>>>>>> Thanks
>>>>>>> Yigal
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
|
|
|
Re: Search for all references to a specific instance [message #118014 is a reply to message #117458] |
Sat, 12 April 2008 17:11  |
Eclipse User |
|
|
|
Hi Yigal,
I had missed this post. The change you propose was made a few months back (build,
0.8.0.I200802110503). So using a later build should solve this.
gr. Martin
Yigal wrote:
> Martin,
> Looking at other section of the code it seems to me that the code should
> be:
> (on line 932) the code is:
> if (classDone.contains(eclass)) {
> return refersTo.get(ens.toEntityName(eclass));
> }
>
> Yigal
>
> Yigal wrote:
>> Hi Martin,
>> I Debug through the initialization code in the HbDataStore class.
>> When it builds the refers to supper class list, there is an issue with
>> the code:
>>
>> (on line 932) the code is:
>> if (classDone.contains(eclass)) {
>> return refersTo.get(eclass);
>> }
>> In my case, the "screw" as a supper that is a "Part". The "Part" was
>> already in the list of classDone so the classDone.contains returns true.
>> However the refertTo does not have it so it returns a NULL and
>> therefore the method addUnique fails becuase the list is empty. (l2
>> == null);
>>
>> It seems to me the code needs to validate that the class is in
>> refersTo and not just in classDone.
>>
>> Yigal
>>
>>
>>
>> Martin Taal wrote:
>>> Hi Yigal,
>>> This should work fine for the subclass also. The computeReferers ends
>>> up in the setRefersToOfSupers method, this method should copy all
>>> found references from the parent class to subclass. Can you
>>> check/debug why it does not do that for the subclass?
>>>
>>> gr. Martin
>>>
>>> Yigal wrote:
>>>> Hi Martin,
>>>> Thanks for the advise, I debug the code and here is what I found:
>>>> My "screw" class extends the class called "Part". Since the engines
>>>> has different parts, I keep a reference list of "Parts" for the engine.
>>>>
>>>> So when I run the getCrossReferencers, the method search for "Screw"
>>>> class, while the only reference list is a "Part". If I change the
>>>> value from screw to part the method returns the correct engine value.
>>>>
>>>> DO you have any ideas how to call the getCrossReferencers with an
>>>> object but make it look make it look for the parent class as well?
>>>> Should I rewrite the method?
>>>>
>>>> Thanks
>>>> Yigal
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Hi Yigal,
>>>>> No special ideas, the way you use it is fine. I would debug into
>>>>> the getCrossReferencers method to see what it does/why it does not
>>>>> work.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Yigal wrote:
>>>>>> Hi Martin,
>>>>>> This is the exact methid I'm looking for. Can you help with some
>>>>>> sample code?
>>>>>> I tried the following code:
>>>>>>
>>>>>> // Get the data store from valid repository
>>>>>> HbDataStore dStore = myRepository.getDataStore ();
>>>>>> // Open a session
>>>>>> Session sc = ds.getSessionFactory().openSession();
>>>>>> // Get referencers
>>>>>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>>>>>
>>>>>> When I run this I get ZERO items, regardless for number of
>>>>>> references.
>>>>>>
>>>>>> Any ideas?
>>>>>>
>>>>>> Thanks
>>>>>> Yigal
>>>>>>
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Hi Yigal,
>>>>>>> The datastore has the getCrossReferencers method for that.
>>>>>>> When the datastore is initialized it analyzes the internal
>>>>>>> datamodel and for each reference creates the query required to
>>>>>>> get the refered-to. The getCrossReferencers method re-uses this
>>>>>>> information to query the db.
>>>>>>> Note that if the amount of referees can be very large then
>>>>>>> getCrossReferencers can still be performance intensive.
>>>>>>> A possible improvement can be that you also pass the maximum
>>>>>>> number of objects you want to receive back. So that the search
>>>>>>> can be limited or stops earlier.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Yigal wrote:
>>>>>>>> I'm using TENEO and hibernate on a very large model and complex
>>>>>>>> relationships (references).
>>>>>>>> I want to create a class that gives me all the parent instances
>>>>>>>> that reference one specific child instance.
>>>>>>>> For example:
>>>>>>>> Let assume I have an eCore model that represent a car. The
>>>>>>>> engine (one class) as a reference (association) to screw (common
>>>>>>>> class) that is used in the engine. The same for the
>>>>>>>> transmission, AC and etc. That means in the model the class
>>>>>>>> instance "screw1" is referenced by many other instances of the
>>>>>>>> other classes.
>>>>>>>> If I have an instance of "screw1", I want to find out which
>>>>>>>> instance references this "screw1" (for example write a report if
>>>>>>>> the screw changes which component gets impacted - engine
>>>>>>>> transmission and etc.).
>>>>>>>>
>>>>>>>> Since my database is large, I disabled the Hibernate option to
>>>>>>>> load all top classes when a new resource is created.
>>>>>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>>>>>> resourceSet), but it does not return any information.
>>>>>>>>
>>>>>>>> How can I search the entire database to find all the references
>>>>>>>> to a single instance?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Yigal
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
--
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: Search for all references to a specific instance [message #616080 is a reply to message #116908] |
Fri, 04 April 2008 14:58  |
Eclipse User |
|
|
|
Hi Yigal,
The datastore has the getCrossReferencers method for that.
When the datastore is initialized it analyzes the internal datamodel and for each reference creates
the query required to get the refered-to. The getCrossReferencers method re-uses this information to
query the db.
Note that if the amount of referees can be very large then getCrossReferencers can still be
performance intensive.
A possible improvement can be that you also pass the maximum number of objects you want to receive
back. So that the search can be limited or stops earlier.
gr. Martin
Yigal wrote:
> I'm using TENEO and hibernate on a very large model and complex
> relationships (references).
> I want to create a class that gives me all the parent instances that
> reference one specific child instance.
> For example:
> Let assume I have an eCore model that represent a car. The engine (one
> class) as a reference (association) to screw (common class) that is used
> in the engine. The same for the transmission, AC and etc. That means
> in the model the class instance "screw1" is referenced by many other
> instances of the other classes.
> If I have an instance of "screw1", I want to find out which instance
> references this "screw1" (for example write a report if the screw
> changes which component gets impacted - engine transmission and etc.).
>
> Since my database is large, I disabled the Hibernate option to load all
> top classes when a new resource is created.
> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
> resourceSet), but it does not return any information.
>
> How can I search the entire database to find all the references to a
> single instance?
>
> Thanks
> Yigal
--
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: Search for all references to a specific instance [message #616081 is a reply to message #116935] |
Sat, 05 April 2008 19:14  |
Eclipse User |
|
|
|
Hi Martin,
This is the exact methid I'm looking for. Can you help with some sample
code?
I tried the following code:
// Get the data store from valid repository
HbDataStore dStore = myRepository.getDataStore ();
// Open a session
Session sc = ds.getSessionFactory().openSession();
// Get referencers
Object [] objs = ds.getCrossReferencers(sc, screw1);
When I run this I get ZERO items, regardless for number of references.
Any ideas?
Thanks
Yigal
Martin Taal wrote:
> Hi Yigal,
> The datastore has the getCrossReferencers method for that.
> When the datastore is initialized it analyzes the internal datamodel and
> for each reference creates the query required to get the refered-to. The
> getCrossReferencers method re-uses this information to query the db.
> Note that if the amount of referees can be very large then
> getCrossReferencers can still be performance intensive.
> A possible improvement can be that you also pass the maximum number of
> objects you want to receive back. So that the search can be limited or
> stops earlier.
>
> gr. Martin
>
> Yigal wrote:
>> I'm using TENEO and hibernate on a very large model and complex
>> relationships (references).
>> I want to create a class that gives me all the parent instances that
>> reference one specific child instance.
>> For example:
>> Let assume I have an eCore model that represent a car. The engine
>> (one class) as a reference (association) to screw (common class) that
>> is used in the engine. The same for the transmission, AC and etc.
>> That means in the model the class instance "screw1" is referenced by
>> many other instances of the other classes.
>> If I have an instance of "screw1", I want to find out which instance
>> references this "screw1" (for example write a report if the screw
>> changes which component gets impacted - engine transmission and etc.).
>>
>> Since my database is large, I disabled the Hibernate option to load
>> all top classes when a new resource is created.
>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>> resourceSet), but it does not return any information.
>>
>> How can I search the entire database to find all the references to a
>> single instance?
>>
>> Thanks
>> Yigal
>
>
|
|
|
Re: Search for all references to a specific instance [message #616085 is a reply to message #116948] |
Sun, 06 April 2008 06:08  |
Eclipse User |
|
|
|
Hi Yigal,
No special ideas, the way you use it is fine. I would debug into the getCrossReferencers method to
see what it does/why it does not work.
gr. Martin
Yigal wrote:
> Hi Martin,
> This is the exact methid I'm looking for. Can you help with some sample
> code?
> I tried the following code:
>
> // Get the data store from valid repository
> HbDataStore dStore = myRepository.getDataStore ();
> // Open a session
> Session sc = ds.getSessionFactory().openSession();
> // Get referencers
> Object [] objs = ds.getCrossReferencers(sc, screw1);
>
> When I run this I get ZERO items, regardless for number of references.
>
> Any ideas?
>
> Thanks
> Yigal
>
>
> Martin Taal wrote:
>> Hi Yigal,
>> The datastore has the getCrossReferencers method for that.
>> When the datastore is initialized it analyzes the internal datamodel
>> and for each reference creates the query required to get the
>> refered-to. The getCrossReferencers method re-uses this information to
>> query the db.
>> Note that if the amount of referees can be very large then
>> getCrossReferencers can still be performance intensive.
>> A possible improvement can be that you also pass the maximum number of
>> objects you want to receive back. So that the search can be limited or
>> stops earlier.
>>
>> gr. Martin
>>
>> Yigal wrote:
>>> I'm using TENEO and hibernate on a very large model and complex
>>> relationships (references).
>>> I want to create a class that gives me all the parent instances that
>>> reference one specific child instance.
>>> For example:
>>> Let assume I have an eCore model that represent a car. The engine
>>> (one class) as a reference (association) to screw (common class) that
>>> is used in the engine. The same for the transmission, AC and etc.
>>> That means in the model the class instance "screw1" is referenced by
>>> many other instances of the other classes.
>>> If I have an instance of "screw1", I want to find out which instance
>>> references this "screw1" (for example write a report if the screw
>>> changes which component gets impacted - engine transmission and etc.).
>>>
>>> Since my database is large, I disabled the Hibernate option to load
>>> all top classes when a new resource is created.
>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>> resourceSet), but it does not return any information.
>>>
>>> How can I search the entire database to find all the references to a
>>> single instance?
>>>
>>> Thanks
>>> Yigal
>>
>>
--
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: Search for all references to a specific instance [message #616086 is a reply to message #117000] |
Sun, 06 April 2008 09:34  |
Eclipse User |
|
|
|
Hi Martin,
Thanks for the advise, I debug the code and here is what I found:
My "screw" class extends the class called "Part". Since the engines has
different parts, I keep a reference list of "Parts" for the engine.
So when I run the getCrossReferencers, the method search for "Screw"
class, while the only reference list is a "Part". If I change the value
from screw to part the method returns the correct engine value.
DO you have any ideas how to call the getCrossReferencers with an object
but make it look make it look for the parent class as well?
Should I rewrite the method?
Thanks
Yigal
Martin Taal wrote:
> Hi Yigal,
> No special ideas, the way you use it is fine. I would debug into the
> getCrossReferencers method to see what it does/why it does not work.
>
> gr. Martin
>
> Yigal wrote:
>> Hi Martin,
>> This is the exact methid I'm looking for. Can you help with some
>> sample code?
>> I tried the following code:
>>
>> // Get the data store from valid repository
>> HbDataStore dStore = myRepository.getDataStore ();
>> // Open a session
>> Session sc = ds.getSessionFactory().openSession();
>> // Get referencers
>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>
>> When I run this I get ZERO items, regardless for number of references.
>>
>> Any ideas?
>>
>> Thanks
>> Yigal
>>
>>
>> Martin Taal wrote:
>>> Hi Yigal,
>>> The datastore has the getCrossReferencers method for that.
>>> When the datastore is initialized it analyzes the internal datamodel
>>> and for each reference creates the query required to get the
>>> refered-to. The getCrossReferencers method re-uses this information
>>> to query the db.
>>> Note that if the amount of referees can be very large then
>>> getCrossReferencers can still be performance intensive.
>>> A possible improvement can be that you also pass the maximum number
>>> of objects you want to receive back. So that the search can be
>>> limited or stops earlier.
>>>
>>> gr. Martin
>>>
>>> Yigal wrote:
>>>> I'm using TENEO and hibernate on a very large model and complex
>>>> relationships (references).
>>>> I want to create a class that gives me all the parent instances that
>>>> reference one specific child instance.
>>>> For example:
>>>> Let assume I have an eCore model that represent a car. The engine
>>>> (one class) as a reference (association) to screw (common class)
>>>> that is used in the engine. The same for the transmission, AC and
>>>> etc. That means in the model the class instance "screw1" is
>>>> referenced by many other instances of the other classes.
>>>> If I have an instance of "screw1", I want to find out which instance
>>>> references this "screw1" (for example write a report if the screw
>>>> changes which component gets impacted - engine transmission and etc.).
>>>>
>>>> Since my database is large, I disabled the Hibernate option to load
>>>> all top classes when a new resource is created.
>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>> resourceSet), but it does not return any information.
>>>>
>>>> How can I search the entire database to find all the references to a
>>>> single instance?
>>>>
>>>> Thanks
>>>> Yigal
>>>
>>>
>
>
|
|
|
Re: Search for all references to a specific instance [message #616087 is a reply to message #117012] |
Sun, 06 April 2008 10:12  |
Eclipse User |
|
|
|
Hi Yigal,
This should work fine for the subclass also. The computeReferers ends up in the setRefersToOfSupers
method, this method should copy all found references from the parent class to subclass. Can you
check/debug why it does not do that for the subclass?
gr. Martin
Yigal wrote:
> Hi Martin,
> Thanks for the advise, I debug the code and here is what I found:
> My "screw" class extends the class called "Part". Since the engines has
> different parts, I keep a reference list of "Parts" for the engine.
>
> So when I run the getCrossReferencers, the method search for "Screw"
> class, while the only reference list is a "Part". If I change the value
> from screw to part the method returns the correct engine value.
>
> DO you have any ideas how to call the getCrossReferencers with an object
> but make it look make it look for the parent class as well?
> Should I rewrite the method?
>
> Thanks
> Yigal
>
>
> Martin Taal wrote:
>> Hi Yigal,
>> No special ideas, the way you use it is fine. I would debug into the
>> getCrossReferencers method to see what it does/why it does not work.
>>
>> gr. Martin
>>
>> Yigal wrote:
>>> Hi Martin,
>>> This is the exact methid I'm looking for. Can you help with some
>>> sample code?
>>> I tried the following code:
>>>
>>> // Get the data store from valid repository
>>> HbDataStore dStore = myRepository.getDataStore ();
>>> // Open a session
>>> Session sc = ds.getSessionFactory().openSession();
>>> // Get referencers
>>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>>
>>> When I run this I get ZERO items, regardless for number of references.
>>>
>>> Any ideas?
>>>
>>> Thanks
>>> Yigal
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Yigal,
>>>> The datastore has the getCrossReferencers method for that.
>>>> When the datastore is initialized it analyzes the internal datamodel
>>>> and for each reference creates the query required to get the
>>>> refered-to. The getCrossReferencers method re-uses this information
>>>> to query the db.
>>>> Note that if the amount of referees can be very large then
>>>> getCrossReferencers can still be performance intensive.
>>>> A possible improvement can be that you also pass the maximum number
>>>> of objects you want to receive back. So that the search can be
>>>> limited or stops earlier.
>>>>
>>>> gr. Martin
>>>>
>>>> Yigal wrote:
>>>>> I'm using TENEO and hibernate on a very large model and complex
>>>>> relationships (references).
>>>>> I want to create a class that gives me all the parent instances
>>>>> that reference one specific child instance.
>>>>> For example:
>>>>> Let assume I have an eCore model that represent a car. The engine
>>>>> (one class) as a reference (association) to screw (common class)
>>>>> that is used in the engine. The same for the transmission, AC and
>>>>> etc. That means in the model the class instance "screw1" is
>>>>> referenced by many other instances of the other classes.
>>>>> If I have an instance of "screw1", I want to find out which
>>>>> instance references this "screw1" (for example write a report if
>>>>> the screw changes which component gets impacted - engine
>>>>> transmission and etc.).
>>>>>
>>>>> Since my database is large, I disabled the Hibernate option to load
>>>>> all top classes when a new resource is created.
>>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>>> resourceSet), but it does not return any information.
>>>>>
>>>>> How can I search the entire database to find all the references to
>>>>> a single instance?
>>>>>
>>>>> Thanks
>>>>> Yigal
>>>>
>>>>
>>
>>
--
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: Search for all references to a specific instance [message #616137 is a reply to message #117026] |
Wed, 09 April 2008 11:46  |
Eclipse User |
|
|
|
Hi Martin,
I Debug through the initialization code in the HbDataStore class.
When it builds the refers to supper class list, there is an issue with
the code:
(on line 932) the code is:
if (classDone.contains(eclass)) {
return refersTo.get(eclass);
}
In my case, the "screw" as a supper that is a "Part". The "Part" was
already in the list of classDone so the classDone.contains returns true.
However the refertTo does not have it so it returns a NULL and therefore
the method addUnique fails becuase the list is empty. (l2 == null);
It seems to me the code needs to validate that the class is in refersTo
and not just in classDone.
Yigal
Martin Taal wrote:
> Hi Yigal,
> This should work fine for the subclass also. The computeReferers ends up
> in the setRefersToOfSupers method, this method should copy all found
> references from the parent class to subclass. Can you check/debug why it
> does not do that for the subclass?
>
> gr. Martin
>
> Yigal wrote:
>> Hi Martin,
>> Thanks for the advise, I debug the code and here is what I found:
>> My "screw" class extends the class called "Part". Since the engines
>> has different parts, I keep a reference list of "Parts" for the engine.
>>
>> So when I run the getCrossReferencers, the method search for "Screw"
>> class, while the only reference list is a "Part". If I change the
>> value from screw to part the method returns the correct engine value.
>>
>> DO you have any ideas how to call the getCrossReferencers with an
>> object but make it look make it look for the parent class as well?
>> Should I rewrite the method?
>>
>> Thanks
>> Yigal
>>
>>
>> Martin Taal wrote:
>>> Hi Yigal,
>>> No special ideas, the way you use it is fine. I would debug into the
>>> getCrossReferencers method to see what it does/why it does not work.
>>>
>>> gr. Martin
>>>
>>> Yigal wrote:
>>>> Hi Martin,
>>>> This is the exact methid I'm looking for. Can you help with some
>>>> sample code?
>>>> I tried the following code:
>>>>
>>>> // Get the data store from valid repository
>>>> HbDataStore dStore = myRepository.getDataStore ();
>>>> // Open a session
>>>> Session sc = ds.getSessionFactory().openSession();
>>>> // Get referencers
>>>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>>>
>>>> When I run this I get ZERO items, regardless for number of references.
>>>>
>>>> Any ideas?
>>>>
>>>> Thanks
>>>> Yigal
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Hi Yigal,
>>>>> The datastore has the getCrossReferencers method for that.
>>>>> When the datastore is initialized it analyzes the internal
>>>>> datamodel and for each reference creates the query required to get
>>>>> the refered-to. The getCrossReferencers method re-uses this
>>>>> information to query the db.
>>>>> Note that if the amount of referees can be very large then
>>>>> getCrossReferencers can still be performance intensive.
>>>>> A possible improvement can be that you also pass the maximum number
>>>>> of objects you want to receive back. So that the search can be
>>>>> limited or stops earlier.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Yigal wrote:
>>>>>> I'm using TENEO and hibernate on a very large model and complex
>>>>>> relationships (references).
>>>>>> I want to create a class that gives me all the parent instances
>>>>>> that reference one specific child instance.
>>>>>> For example:
>>>>>> Let assume I have an eCore model that represent a car. The engine
>>>>>> (one class) as a reference (association) to screw (common class)
>>>>>> that is used in the engine. The same for the transmission, AC and
>>>>>> etc. That means in the model the class instance "screw1" is
>>>>>> referenced by many other instances of the other classes.
>>>>>> If I have an instance of "screw1", I want to find out which
>>>>>> instance references this "screw1" (for example write a report if
>>>>>> the screw changes which component gets impacted - engine
>>>>>> transmission and etc.).
>>>>>>
>>>>>> Since my database is large, I disabled the Hibernate option to
>>>>>> load all top classes when a new resource is created.
>>>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>>>> resourceSet), but it does not return any information.
>>>>>>
>>>>>> How can I search the entire database to find all the references to
>>>>>> a single instance?
>>>>>>
>>>>>> Thanks
>>>>>> Yigal
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: Search for all references to a specific instance [message #616143 is a reply to message #117431] |
Wed, 09 April 2008 12:07  |
Eclipse User |
|
|
|
Martin,
Looking at other section of the code it seems to me that the code should be:
(on line 932) the code is:
if (classDone.contains(eclass)) {
return refersTo.get(ens.toEntityName(eclass));
}
Yigal
Yigal wrote:
> Hi Martin,
> I Debug through the initialization code in the HbDataStore class.
> When it builds the refers to supper class list, there is an issue with
> the code:
>
> (on line 932) the code is:
> if (classDone.contains(eclass)) {
> return refersTo.get(eclass);
> }
> In my case, the "screw" as a supper that is a "Part". The "Part" was
> already in the list of classDone so the classDone.contains returns true.
> However the refertTo does not have it so it returns a NULL and therefore
> the method addUnique fails becuase the list is empty. (l2 == null);
>
> It seems to me the code needs to validate that the class is in refersTo
> and not just in classDone.
>
> Yigal
>
>
>
> Martin Taal wrote:
>> Hi Yigal,
>> This should work fine for the subclass also. The computeReferers ends
>> up in the setRefersToOfSupers method, this method should copy all
>> found references from the parent class to subclass. Can you
>> check/debug why it does not do that for the subclass?
>>
>> gr. Martin
>>
>> Yigal wrote:
>>> Hi Martin,
>>> Thanks for the advise, I debug the code and here is what I found:
>>> My "screw" class extends the class called "Part". Since the engines
>>> has different parts, I keep a reference list of "Parts" for the engine.
>>>
>>> So when I run the getCrossReferencers, the method search for "Screw"
>>> class, while the only reference list is a "Part". If I change the
>>> value from screw to part the method returns the correct engine value.
>>>
>>> DO you have any ideas how to call the getCrossReferencers with an
>>> object but make it look make it look for the parent class as well?
>>> Should I rewrite the method?
>>>
>>> Thanks
>>> Yigal
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Yigal,
>>>> No special ideas, the way you use it is fine. I would debug into the
>>>> getCrossReferencers method to see what it does/why it does not work.
>>>>
>>>> gr. Martin
>>>>
>>>> Yigal wrote:
>>>>> Hi Martin,
>>>>> This is the exact methid I'm looking for. Can you help with some
>>>>> sample code?
>>>>> I tried the following code:
>>>>>
>>>>> // Get the data store from valid repository
>>>>> HbDataStore dStore = myRepository.getDataStore ();
>>>>> // Open a session
>>>>> Session sc = ds.getSessionFactory().openSession();
>>>>> // Get referencers
>>>>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>>>>
>>>>> When I run this I get ZERO items, regardless for number of references.
>>>>>
>>>>> Any ideas?
>>>>>
>>>>> Thanks
>>>>> Yigal
>>>>>
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi Yigal,
>>>>>> The datastore has the getCrossReferencers method for that.
>>>>>> When the datastore is initialized it analyzes the internal
>>>>>> datamodel and for each reference creates the query required to get
>>>>>> the refered-to. The getCrossReferencers method re-uses this
>>>>>> information to query the db.
>>>>>> Note that if the amount of referees can be very large then
>>>>>> getCrossReferencers can still be performance intensive.
>>>>>> A possible improvement can be that you also pass the maximum
>>>>>> number of objects you want to receive back. So that the search can
>>>>>> be limited or stops earlier.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Yigal wrote:
>>>>>>> I'm using TENEO and hibernate on a very large model and complex
>>>>>>> relationships (references).
>>>>>>> I want to create a class that gives me all the parent instances
>>>>>>> that reference one specific child instance.
>>>>>>> For example:
>>>>>>> Let assume I have an eCore model that represent a car. The
>>>>>>> engine (one class) as a reference (association) to screw (common
>>>>>>> class) that is used in the engine. The same for the
>>>>>>> transmission, AC and etc. That means in the model the class
>>>>>>> instance "screw1" is referenced by many other instances of the
>>>>>>> other classes.
>>>>>>> If I have an instance of "screw1", I want to find out which
>>>>>>> instance references this "screw1" (for example write a report if
>>>>>>> the screw changes which component gets impacted - engine
>>>>>>> transmission and etc.).
>>>>>>>
>>>>>>> Since my database is large, I disabled the Hibernate option to
>>>>>>> load all top classes when a new resource is created.
>>>>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>>>>> resourceSet), but it does not return any information.
>>>>>>>
>>>>>>> How can I search the entire database to find all the references
>>>>>>> to a single instance?
>>>>>>>
>>>>>>> Thanks
>>>>>>> Yigal
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
|
|
|
Re: Search for all references to a specific instance [message #616235 is a reply to message #117458] |
Sat, 12 April 2008 17:11  |
Eclipse User |
|
|
|
Hi Yigal,
I had missed this post. The change you propose was made a few months back (build,
0.8.0.I200802110503). So using a later build should solve this.
gr. Martin
Yigal wrote:
> Martin,
> Looking at other section of the code it seems to me that the code should
> be:
> (on line 932) the code is:
> if (classDone.contains(eclass)) {
> return refersTo.get(ens.toEntityName(eclass));
> }
>
> Yigal
>
> Yigal wrote:
>> Hi Martin,
>> I Debug through the initialization code in the HbDataStore class.
>> When it builds the refers to supper class list, there is an issue with
>> the code:
>>
>> (on line 932) the code is:
>> if (classDone.contains(eclass)) {
>> return refersTo.get(eclass);
>> }
>> In my case, the "screw" as a supper that is a "Part". The "Part" was
>> already in the list of classDone so the classDone.contains returns true.
>> However the refertTo does not have it so it returns a NULL and
>> therefore the method addUnique fails becuase the list is empty. (l2
>> == null);
>>
>> It seems to me the code needs to validate that the class is in
>> refersTo and not just in classDone.
>>
>> Yigal
>>
>>
>>
>> Martin Taal wrote:
>>> Hi Yigal,
>>> This should work fine for the subclass also. The computeReferers ends
>>> up in the setRefersToOfSupers method, this method should copy all
>>> found references from the parent class to subclass. Can you
>>> check/debug why it does not do that for the subclass?
>>>
>>> gr. Martin
>>>
>>> Yigal wrote:
>>>> Hi Martin,
>>>> Thanks for the advise, I debug the code and here is what I found:
>>>> My "screw" class extends the class called "Part". Since the engines
>>>> has different parts, I keep a reference list of "Parts" for the engine.
>>>>
>>>> So when I run the getCrossReferencers, the method search for "Screw"
>>>> class, while the only reference list is a "Part". If I change the
>>>> value from screw to part the method returns the correct engine value.
>>>>
>>>> DO you have any ideas how to call the getCrossReferencers with an
>>>> object but make it look make it look for the parent class as well?
>>>> Should I rewrite the method?
>>>>
>>>> Thanks
>>>> Yigal
>>>>
>>>>
>>>> Martin Taal wrote:
>>>>> Hi Yigal,
>>>>> No special ideas, the way you use it is fine. I would debug into
>>>>> the getCrossReferencers method to see what it does/why it does not
>>>>> work.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Yigal wrote:
>>>>>> Hi Martin,
>>>>>> This is the exact methid I'm looking for. Can you help with some
>>>>>> sample code?
>>>>>> I tried the following code:
>>>>>>
>>>>>> // Get the data store from valid repository
>>>>>> HbDataStore dStore = myRepository.getDataStore ();
>>>>>> // Open a session
>>>>>> Session sc = ds.getSessionFactory().openSession();
>>>>>> // Get referencers
>>>>>> Object [] objs = ds.getCrossReferencers(sc, screw1);
>>>>>>
>>>>>> When I run this I get ZERO items, regardless for number of
>>>>>> references.
>>>>>>
>>>>>> Any ideas?
>>>>>>
>>>>>> Thanks
>>>>>> Yigal
>>>>>>
>>>>>>
>>>>>> Martin Taal wrote:
>>>>>>> Hi Yigal,
>>>>>>> The datastore has the getCrossReferencers method for that.
>>>>>>> When the datastore is initialized it analyzes the internal
>>>>>>> datamodel and for each reference creates the query required to
>>>>>>> get the refered-to. The getCrossReferencers method re-uses this
>>>>>>> information to query the db.
>>>>>>> Note that if the amount of referees can be very large then
>>>>>>> getCrossReferencers can still be performance intensive.
>>>>>>> A possible improvement can be that you also pass the maximum
>>>>>>> number of objects you want to receive back. So that the search
>>>>>>> can be limited or stops earlier.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Yigal wrote:
>>>>>>>> I'm using TENEO and hibernate on a very large model and complex
>>>>>>>> relationships (references).
>>>>>>>> I want to create a class that gives me all the parent instances
>>>>>>>> that reference one specific child instance.
>>>>>>>> For example:
>>>>>>>> Let assume I have an eCore model that represent a car. The
>>>>>>>> engine (one class) as a reference (association) to screw (common
>>>>>>>> class) that is used in the engine. The same for the
>>>>>>>> transmission, AC and etc. That means in the model the class
>>>>>>>> instance "screw1" is referenced by many other instances of the
>>>>>>>> other classes.
>>>>>>>> If I have an instance of "screw1", I want to find out which
>>>>>>>> instance references this "screw1" (for example write a report if
>>>>>>>> the screw changes which component gets impacted - engine
>>>>>>>> transmission and etc.).
>>>>>>>>
>>>>>>>> Since my database is large, I disabled the Hibernate option to
>>>>>>>> load all top classes when a new resource is created.
>>>>>>>> I used the utility EcoreUtil.UsageCrossReference.find(<screw1>,
>>>>>>>> resourceSet), but it does not return any information.
>>>>>>>>
>>>>>>>> How can I search the entire database to find all the references
>>>>>>>> to a single instance?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Yigal
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
--
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
|
|
|
Goto Forum:
Current Time: Thu May 08 07:59:38 EDT 2025
Powered by FUDForum. Page generated in 0.07896 seconds
|