JPOXLogger.DATASTORE.debug("AbstractSetStore::remove element=" + element + " doesn't exist in this Set.");
return false;
}
boolean modified = false;
ObjectManager om = sm.getObjectManager();
String removeStmt = getRemoveStmt();
try
{
ManagedConnection mconn = storeMgr.getConnection(om);
SQLController sqlControl = storeMgr.getSQLController();
try
{
PreparedStatement ps = sqlControl.getStatementForUpdate(mconn, removeStmt, false);
try
{
int jdbcPosition = 1;
jdbcPosition = populateOwnerInStatement(sm, om, ps, jdbcPosition);
jdbcPosition = populateElementInStatement(om, ps, element, jdbcPosition);
if (relationDiscriminatorMapping != null)
{
jdbcPosition = populateRelationDiscriminatorInStatement(om, ps, jdbcPosition);
}
int[] rowsDeleted = sqlControl.executeStatementUpdate(mconn, removeStmt, ps, true);
modified = (rowsDeleted[0] == 1);
}
finally
{
sqlControl.closeStatement(mconn, ps);
}
}
finally
{
mconn.release();
}
}
catch (SQLException e)
{
JPOXLogger.DATASTORE.error(e);
String msg = LOCALISER.msg("056012",removeStmt);
JPOXLogger.DATASTORE.error(msg);
throw new JPOXDataStoreException(msg, e);
}
CollectionMetaData collmd = ownerMemberMetaData.getCollection();
if (allowDependentField && collmd.isDependentElement() && !collmd.isEmbeddedElement())
{
// TODO Could this element be stored as a duplicate in this set ?
// Delete the element if it is dependent
om.deleteObjectInternal(element);
}
return modified;
}