public T execute ( DatabaseConnection databaseConnection , ID id , ObjectCache objectCache ) throws SQLException { if ( objectCache != null ) { T result = objectCache . get ( clazz , id ) ; if ( result != null ) { return result ; } } Object [ ] args = new Object [ ] { convertIdToFieldObject ( id ) } ; // @SuppressWarnings("unchecked") Object result = databaseConnection . queryForOne ( statement , args , argFieldTypes , this , objectCache ) ; if ( result == null ) { logger . debug ( "{} using '{}' and {} args, got no results" , label , statement , args . length ) ; } else if ( result == DatabaseConnection . MORE_THAN_ONE ) { logger . error ( "{} using '{}' and {} args, got >1 results" , label , statement , args . length ) ; logArgs ( args ) ; throw new SQLException ( label + " got more than 1 result: " + statement ) ; } else { logger . debug ( "{} using '{}' and {} args, got 1 result" , label , statement , args . length ) ; } logArgs ( args ) ; @ SuppressWarnings ( "unchecked" ) T castResult = ( T ) result ; return castResult ; }
Query for an object in the database which matches the id argument .