Home » Modeling » EMF » [CDO] org.eclipse.emf.cdo.util.ObjectNotFoundException dangling EReference?
| |
Re: [CDO] org.eclipse.emf.cdo.util.ObjectNotFoundException dangling EReference? [message #756028 is a reply to message #756022] |
Thu, 10 November 2011 14:12 |
Christophe Bouhier Messages: 937 Registered: July 2009 |
Senior Member |
|
|
Hi David,
I get this also sometimes, (Although I am sure when I add a
non-containment reference, the "dangler" is actually in a resource....So
much on why this happens....
On how to remove them, this works for me: (Use at own risk!).
// Check dangling.
for (EObject object : listOfObjectsToStore) {
TreeIterator<EObject> eAllContents = object.eAllContents();
while(eAllContents.hasNext()){
EObject next = eAllContents.next();
EList<EReference> eAllReferences = next.eClass().getEAllReferences();
for( EReference eRef : eAllReferences){
if(!next.eIsSet(eRef)){
// continue, only filled ERefs.
continue;
}
if(eRef.isMany()){
Object eGet = next.eGet(eRef);
List<? extends EObject> collection = (List<? extends EObject>) eGet;
List<EObject> toRemove = Lists.newArrayList();
for(EObject eo : collection ){
if(isDangling(eo, eRef)){
int index = collection.indexOf(eo);
toRemove.add(collection.get(index));
}
}
for(EObject eo : toRemove){
collection.remove(eo);
}
}else{
Object eGet = next.eGet(eRef);
EObject eo = (EObject) eGet;
if(isDangling(eo, eRef)){
this.unsetDangling(next, eRef);
}
}
}
}
On 10-11-11 14:52, David Wynter wrote:
> Hi,
>
> To get past this I did this. But would still like to understand how this
> can occur to a CDO Resource and how to remove the dangling references.
>
> ResourceMap aResMap = null;
> for(int i=0; i < resourceMaps.size(); i++) {
> try {
> aResMap = resourceMaps.get(i);
> break;
> } catch(ObjectNotFoundException onf) {
> // Ignore, later remove dangling reference if possible
> }
> }
>
>
> On 10/11/11 13:27, David Wynter wrote:
>> Hi,
>>
>> I use the following to try to get the latest revision of what is suppose
>> to be the only instance of a ResourceMap class in my repo.
>> But now there appears to be 3 of them, which is fine, I see them in the
>> List when I inspect it. Except it throws an
>> org.eclipse.emf.cdo.util.ObjectNotFoundException where it gets the 0
>> indexed List element. How can this be? I assume there is a EReference to
>> a non existing object, Can I progromatically remove these dangling
>> references (how do they happen in the first place? I always use
>> transactions)
>>
>> Is there a better way of doing this?
>>
>> CDOSession aSession = EDMCDOSession.getSession();
>> aTransaction = aSession.openTransaction();
>> CDOQuery cdoQuery = aTransaction.createQuery("sql", "SELECT DISTINCT
>> CDO_ID FROM ResourceMap WHERE ResourceMap.CDO_REVISED = 0");
>> List<ResourceMap> resourceMaps = cdoQuery.getResult(ResourceMap.class);
>> ResourceMap aResMap = resourceMaps.get(0);
>>
>> Thx.
>>
>> David
>
|
|
| |
Re: [CDO] org.eclipse.emf.cdo.util.ObjectNotFoundException dangling EReference? [message #756036 is a reply to message #756012] |
Thu, 10 November 2011 14:53 |
Stefan Winkler Messages: 307 Registered: July 2009 Location: Germany |
Senior Member |
|
|
Hi David,
I'm not sure what you are trying to do. The safest thing (and IMO
preferrable to using a query) is using navigation (i.e., open the
resource your object is stored in and use this as an entry point into
the model). SQL Queries should be used for cases in which you want to
quickly access objects based on a domain property (e.g. get all people
with age > 30). Especially relying on CDO-internal columns is risky, as
the CDO schema might be dependent on the database, on the mapping
strategy and on version of CDO.
Also, if you use the branching store, there could be multiple objects
which are not revised (namely all tips of the branches).
If you think, you are hitting a bug with multiple CDO_REVISED = 0
entries, a test case to produce the situation and possibly the output of
"select * from ResourceMap;" would help to approach the bug. Please file
a bugzilla with this information then.
Cheers,
Stefan
Am 10.11.11 14:27, schrieb David Wynter:
> Hi,
>
> I use the following to try to get the latest revision of what is suppose
> to be the only instance of a ResourceMap class in my repo.
> But now there appears to be 3 of them, which is fine, I see them in the
> List when I inspect it. Except it throws an
> org.eclipse.emf.cdo.util.ObjectNotFoundException where it gets the 0
> indexed List element. How can this be? I assume there is a EReference to
> a non existing object, Can I progromatically remove these dangling
> references (how do they happen in the first place? I always use
> transactions)
>
> Is there a better way of doing this?
>
> CDOSession aSession = EDMCDOSession.getSession();
> aTransaction = aSession.openTransaction();
> CDOQuery cdoQuery = aTransaction.createQuery("sql", "SELECT DISTINCT
> CDO_ID FROM ResourceMap WHERE ResourceMap.CDO_REVISED = 0");
> List<ResourceMap> resourceMaps = cdoQuery.getResult(ResourceMap.class);
> ResourceMap aResMap = resourceMaps.get(0);
>
> Thx.
>
> David
|
|
|
Re: [CDO] org.eclipse.emf.cdo.util.ObjectNotFoundException dangling EReference? [message #756702 is a reply to message #756036] |
Mon, 14 November 2011 17:44 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I had previously tried to use navigation. But because of our consistent
problems with dangling objects had to find a way to filter them out,
thus the CDOQuery approach. We only have one ResourceMap and it has all
our text artifacts, like Groovy scripts, bpmn2 XML etc. it is MB in
size, we have > 80,000 objects in the repo. When I get time we will do a
smaller repo.
But I am wondering the best way to detect the moment CDO creates a
dangling exception. We use the CDOTransaction for everything. I am
thinking we will have to keep a record of all our dirty objects, then
after the commit read them all back again and look for dangling
references. Any suggestions on a better way to do this?
This is causing us major problems.
Thx.
David
On 10/11/11 14:53, Stefan Winkler wrote:
> Hi David,
>
> I'm not sure what you are trying to do. The safest thing (and IMO
> preferrable to using a query) is using navigation (i.e., open the
> resource your object is stored in and use this as an entry point into
> the model). SQL Queries should be used for cases in which you want to
> quickly access objects based on a domain property (e.g. get all people
> with age > 30). Especially relying on CDO-internal columns is risky, as
> the CDO schema might be dependent on the database, on the mapping
> strategy and on version of CDO.
>
> Also, if you use the branching store, there could be multiple objects
> which are not revised (namely all tips of the branches).
>
> If you think, you are hitting a bug with multiple CDO_REVISED = 0
> entries, a test case to produce the situation and possibly the output of
> "select * from ResourceMap;" would help to approach the bug. Please file
> a bugzilla with this information then.
>
> Cheers,
> Stefan
>
>
>
>
> Am 10.11.11 14:27, schrieb David Wynter:
>> Hi,
>>
>> I use the following to try to get the latest revision of what is suppose
>> to be the only instance of a ResourceMap class in my repo.
>> But now there appears to be 3 of them, which is fine, I see them in the
>> List when I inspect it. Except it throws an
>> org.eclipse.emf.cdo.util.ObjectNotFoundException where it gets the 0
>> indexed List element. How can this be? I assume there is a EReference to
>> a non existing object, Can I progromatically remove these dangling
>> references (how do they happen in the first place? I always use
>> transactions)
>>
>> Is there a better way of doing this?
>>
>> CDOSession aSession = EDMCDOSession.getSession();
>> aTransaction = aSession.openTransaction();
>> CDOQuery cdoQuery = aTransaction.createQuery("sql", "SELECT DISTINCT
>> CDO_ID FROM ResourceMap WHERE ResourceMap.CDO_REVISED = 0");
>> List<ResourceMap> resourceMaps = cdoQuery.getResult(ResourceMap.class);
>> ResourceMap aResMap = resourceMaps.get(0);
>>
>> Thx.
>>
>> David
>
|
|
| |
Re: [CDO] org.eclipse.emf.cdo.util.ObjectNotFoundException dangling EReference? [message #756798 is a reply to message #756702] |
Tue, 15 November 2011 07:20 |
|
Hi David,
I'm currently with a customer and will not be able to work on this problem before next week. Can you please submit a
bugzilla with detailed descriptions so that I don't forget about it? If you have some spare time it would be very great
if you could repdroduce the problem in our test bed. Please have a look at some of our 2000 test cases and see how easy
it is to write them.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 14.11.2011 18:44, schrieb David Wynter:
> Hi,
>
> I had previously tried to use navigation. But because of our consistent problems with dangling objects had to find a
> way to filter them out, thus the CDOQuery approach. We only have one ResourceMap and it has all our text artifacts,
> like Groovy scripts, bpmn2 XML etc. it is MB in size, we have > 80,000 objects in the repo. When I get time we will do
> a smaller repo.
>
> But I am wondering the best way to detect the moment CDO creates a dangling exception. We use the CDOTransaction for
> everything. I am thinking we will have to keep a record of all our dirty objects, then after the commit read them all
> back again and look for dangling references. Any suggestions on a better way to do this?
>
> This is causing us major problems.
>
> Thx.
>
> David
>
> On 10/11/11 14:53, Stefan Winkler wrote:
>> Hi David,
>>
>> I'm not sure what you are trying to do. The safest thing (and IMO
>> preferrable to using a query) is using navigation (i.e., open the
>> resource your object is stored in and use this as an entry point into
>> the model). SQL Queries should be used for cases in which you want to
>> quickly access objects based on a domain property (e.g. get all people
>> with age > 30). Especially relying on CDO-internal columns is risky, as
>> the CDO schema might be dependent on the database, on the mapping
>> strategy and on version of CDO.
>>
>> Also, if you use the branching store, there could be multiple objects
>> which are not revised (namely all tips of the branches).
>>
>> If you think, you are hitting a bug with multiple CDO_REVISED = 0
>> entries, a test case to produce the situation and possibly the output of
>> "select * from ResourceMap;" would help to approach the bug. Please file
>> a bugzilla with this information then.
>>
>> Cheers,
>> Stefan
>>
>>
>>
>>
>> Am 10.11.11 14:27, schrieb David Wynter:
>>> Hi,
>>>
>>> I use the following to try to get the latest revision of what is suppose
>>> to be the only instance of a ResourceMap class in my repo.
>>> But now there appears to be 3 of them, which is fine, I see them in the
>>> List when I inspect it. Except it throws an
>>> org.eclipse.emf.cdo.util.ObjectNotFoundException where it gets the 0
>>> indexed List element. How can this be? I assume there is a EReference to
>>> a non existing object, Can I progromatically remove these dangling
>>> references (how do they happen in the first place? I always use
>>> transactions)
>>>
>>> Is there a better way of doing this?
>>>
>>> CDOSession aSession = EDMCDOSession.getSession();
>>> aTransaction = aSession.openTransaction();
>>> CDOQuery cdoQuery = aTransaction.createQuery("sql", "SELECT DISTINCT
>>> CDO_ID FROM ResourceMap WHERE ResourceMap.CDO_REVISED = 0");
>>> List<ResourceMap> resourceMaps = cdoQuery.getResult(ResourceMap.class);
>>> ResourceMap aResMap = resourceMaps.get(0);
>>>
>>> Thx.
>>>
>>> David
>>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Goto Forum:
Current Time: Thu Sep 19 15:20:47 GMT 2024
Powered by FUDForum. Page generated in 0.04312 seconds
|