I think I've found a bug with Set.remove.
I tried to remove an element from a persistent set (not
an inverse set) that was not in that set. I expected the
Set.remove() method tro return false, it returned true
thus breaking the contract of the Set interface.
I tried to find the code and I think it is in...
AbstractSetStore.remove(StateManager sm, Object
element)
Looking at the code, the following lines lead me to think
it will return true even if the element did not exists in the
set...
ps.executeUpdate();
if (LOG.isDebugEnabled())
LOG.debug("Time = " +
(System.currentTimeMillis() - startTime) + " ms: " +
removeStmt);
modified = true;
This does not check the number of rows by the query
and so cannot know if there was a row to delet or not.
Would something like this do the job...
int deleteCount = ps.executeUpdate();
if (LOG.isDebugEnabled())
LOG.debug("Time = " +
(System.currentTimeMillis() - startTime) + " ms: " +
removeStmt);
modified = deleteCount == 1;
Maybe an assertion that deleteCount is < 1 would be
good too.
I couldn't find the unit test for this so don;t know if it has
been tested.
Matty.
Mike Martin
Core
v2.0 Beta
Public
|
Date: 2002-12-07 07:24 Logged In: YES |
| Field | Old Value | Date | By |
|---|---|---|---|
| status_id | Open | 2002-12-07 07:24 | jackknifebarber |
| resolution_id | None | 2002-12-07 07:24 | jackknifebarber |
| assigned_to | nobody | 2002-12-07 07:24 | jackknifebarber |
| close_date | - | 2002-12-07 07:24 | jackknifebarber |
Copyright © 2009 Geeknet, Inc. All rights reserved. Terms of Use