Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Exception when removing objects from a list, obtained with query
[CDO] Exception when removing objects from a list, obtained with query [message #998697] Thu, 10 January 2013 14:24 Go to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 919
Registered: July 2009
Senior Member
Hello There,

I have a multi-values feature named 'listforA' which has a bunch of objects named A, which I retrieve from a CDO (SQL) query.
next, I do a ...getListForA().removeAll(List<A>) which throws this exception below.

So apparently this is not supported, what would be the appropriate use case to delete objects obtained from a query? Should I create a query which deletes instead?

thx Christophe

java.lang.UnsupportedOperationException
at org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl$QueryResultList.contains(CDOQueryResultIteratorImpl.java:204)
at org.eclipse.emf.common.util.AbstractEList.getDuplicates(AbstractEList.java:1151)
at org.eclipse.emf.common.notify.impl.DelegatingNotifyingListImpl.removeAll(DelegatingNotifyingListImpl.java:908)
at com.netxforge.netxstudio.data.importer.ResultProcessor.removeValues(ResultProcessor.java:187)
Re: [CDO] Exception when removing objects from a list, obtained with query [message #998755 is a reply to message #998697] Thu, 10 January 2013 16:21 Go to previous messageGo to next message
Per Sterner is currently offline Per Sterner
Messages: 70
Registered: October 2011
Member
My first thought is, where are the items contained? Do you really want to operate with CDOQuery?

But to answer the question (for one item), EcoreUtil.delete(item) should delete an item correctly. (it also checks for cross-references which could be slow)

[Updated on: Thu, 10 January 2013 16:26]

Report message to a moderator

Re: [CDO] Exception when removing objects from a list, obtained with query [message #998758 is a reply to message #998755] Thu, 10 January 2013 16:26 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 919
Registered: July 2009
Senior Member
Thanks Per. Yes I need CDO Query, to reduce the collection of objects based criteria . (In this case a period in time).
I found a solution, but copying the CDO query list result into a new array first, and then remove the bunch from the multi-values feature.
(BTW using DELETE command in a CDO Query is not allowed by the underlying JDBC driver, I get an error:
Can not issue data manipulation statements with executeQuery().)

rgds Christophe
Re: [CDO] Exception when removing objects from a list, obtained with query [message #998798 is a reply to message #998758] Thu, 10 January 2013 18:03 Go to previous messageGo to next message
Per Sterner is currently offline Per Sterner
Messages: 70
Registered: October 2011
Member
I think I am somewhere else Smile.

I actually only use CDOQuery for fetching elements in order to use these.

Are you cleaning the database from unneeded elements?
Re: [CDO] Exception when removing objects from a list, obtained with query [message #998824 is a reply to message #998798] Thu, 10 January 2013 19:07 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 919
Registered: July 2009
Senior Member
yes, exaxtly. It's for cleaning up. We deal with a lot of perishable objects Smile
Re: [CDO] Exception when removing objects from a list, obtained with query [message #999016 is a reply to message #998824] Fri, 11 January 2013 06:39 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5522
Registered: July 2009
Senior Member
Am 10.01.2013 20:07, schrieb Christophe Bouhier:
> yes, exaxtly. It's for cleaning up. We deal with a lot of perishable objects :)
I'm a little confused. Is your question about a problem with deleting CDOObjects or with using CDOQuery results? You're
not trying to call remove() on the list that comes out of CDOQuery.getResult(), are you?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] Exception when removing objects from a list, obtained with query [message #999028 is a reply to message #999016] Fri, 11 January 2013 07:22 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5522
Registered: July 2009
Senior Member
Am 11.01.2013 07:39, schrieb Eike Stepper:
> Am 10.01.2013 20:07, schrieb Christophe Bouhier:
>> yes, exaxtly. It's for cleaning up. We deal with a lot of perishable objects :)
> I'm a little confused. Is your question about a problem with deleting CDOObjects or with using CDOQuery results?
> You're not trying to call remove() on the list that comes out of CDOQuery.getResult(), are you?
So, Ed finally explained to me what you're meaning:

List<A> result = query.getResult();
myObject.getListForA().removeAll(result);

See how easy it can be to explain a problem by pasting some parseable code :P

It seems that some non-optional parts of the list contract have never been implemented by
CDOQueryResultIteratorImpl.QueryResultList<T>. Please submit a bugzilla and I'm sure I can get it to work.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] Exception when removing objects from a list, obtained with query [message #999058 is a reply to message #999028] Fri, 11 January 2013 08:40 Go to previous message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 919
Registered: July 2009
Senior Member
I should really abandon this nasty habit, to "explain" code.
If you don't mind, I used your snippet for the bug Smile

https://bugs.eclipse.org/bugs/show_bug.cgi?id=397948

Cheers Christophe





Previous Topic:Weird call sequence on EStore with containment reference
Next Topic:[GWT] Where to download the runtime components
Goto Forum:
  


Current Time: Wed Sep 17 15:38:11 GMT 2014

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

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