// If no dirty writes, see if that was the issue
if ( !allowsDirtyWrites ) {
// Create the Expression for the Primary Keys
Expression exp = null;
for( MetaField mf : getPrimaryKeys( mc )) {
Expression e = new Expression( mf.getName(), mf.getObject( obj ));
if ( exp == null ) exp = e;
else exp = exp.and( e );
}
if ( exp == null ) throw new PersistenceException( "MetaClass [" + mc + "] has no primary keys defined to delete object [" + obj + "]" );
Collection<Object> results = getDatabaseDriver().readMany( conn, mc, mapping, new QueryOptions( exp ));
if ( results.size() > 0 ) {
throw new DirtyWriteException( obj );
}
}
throw new ObjectNotFoundException( obj );
}
postPersistence( c, mc, obj, DELETE );
}
catch( SQLException e )
{
//log.error( "Unable to delete object of class [" + mc + "]: " + e.getMessage() );
throw new PersistenceException( "Unable to delete object [" + obj + "] of class [" + mc + "]: " + e.getMessage(), e );
}
}