Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forums[CDO] Exception when removing objects from a list, obtained with query
https://www.eclipse.org/forums/index.php/mv/msg/447307/998697/#msg_998697
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)]]>Christophe Bouhier2013-01-10T14:24:46-00:00Re: [CDO] Exception when removing objects from a list, obtained with query
https://www.eclipse.org/forums/index.php/mv/msg/447307/998755/#msg_998755
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)]]>Per Sterner2013-01-10T16:21:44-00:00Re: [CDO] Exception when removing objects from a list, obtained with query
https://www.eclipse.org/forums/index.php/mv/msg/447307/998758/#msg_998758
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]]>Christophe Bouhier2013-01-10T16:26:03-00:00Re: [CDO] Exception when removing objects from a list, obtained with query
https://www.eclipse.org/forums/index.php/mv/msg/447307/998798/#msg_998798
.
I actually only use CDOQuery for fetching elements in order to use these.
Are you cleaning the database from unneeded elements?]]>Per Sterner2013-01-10T18:03:26-00:00Re: [CDO] Exception when removing objects from a list, obtained with query
https://www.eclipse.org/forums/index.php/mv/msg/447307/998824/#msg_998824
]]>Christophe Bouhier2013-01-10T19:07:12-00:00Re: [CDO] Exception when removing objects from a list, obtained with query
https://www.eclipse.org/forums/index.php/mv/msg/447307/999016/#msg_999016
> 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]]>Eike Stepper2013-01-11T06:39:20-00:00Re: [CDO] Exception when removing objects from a list, obtained with query
https://www.eclipse.org/forums/index.php/mv/msg/447307/999028/#msg_999028
> 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]]>Eike Stepper2013-01-11T07:22:46-00:00Re: [CDO] Exception when removing objects from a list, obtained with query
https://www.eclipse.org/forums/index.php/mv/msg/447307/999058/#msg_999058
If you don't mind, I used your snippet for the bug