public int execute ( DatabaseConnection databaseConnection , T data , ID newId , ObjectCache objectCache ) throws SQLException { try { // the arguments are the new-id and old-id Object [ ] args = new Object [ ] { convertIdToFieldObject ( newId ) , extractIdToFieldObject ( data ) } ; int rowC = databaseConnection . update ( statement , args , argFieldTypes ) ; if ( rowC > 0 ) { if ( objectCache != null ) { Object oldId = idField . extractJavaFieldValue ( data ) ; T obj = objectCache . updateId ( clazz , oldId , newId ) ; if ( obj != null && obj != data ) { // if our cached value is not the data that will be updated then we need to update it specially idField . assignField ( connectionSource , obj , newId , false , objectCache ) ; } } // adjust the object to assign the new id idField . assignField ( connectionSource , data , newId , false , objectCache ) ; } logger . debug ( "updating-id with statement '{}' and {} args, changed {} rows" , statement , args . length , rowC ) ; if ( args . length > 0 ) { // need to do the cast otherwise we only print the first object in args logger . trace ( "updating-id arguments: {}" , ( Object ) args ) ; } return rowC ; } catch ( SQLException e ) { throw SqlExceptionUtil . create ( "Unable to run update-id stmt on object " + data + ": " + statement , e ) ; } }
Update the id field of the object in the database .