int setPrimaryKeys ( int index , final Record record , PreparedStatement statement , int opCode ) throws OnRecordErrorException { for ( String key : getPrimaryKeyColumns ( ) ) { Field field = record . get ( recordReader . getFieldPath ( key , getColumnsToFields ( ) , opCode ) ) ; if ( field == null ) { LOG . error ( "Primary key {} is missing in record" , key ) ; throw new OnRecordErrorException ( record , JdbcErrors . JDBC_19 , key ) ; } Object value = field . getValue ( ) ; try { statement . setObject ( index , value , getColumnType ( key ) ) ; } catch ( SQLException ex ) { LOG . error ( "SQLException thrown: {}" , ex . getMessage ( ) ) ; throw new OnRecordErrorException ( record , JdbcErrors . JDBC_19 , key , ex ) ; } ++ index ; } return index ; }
Set primary key values to query . This is called only for UPDATE and DELETE operations . If primary key value is missing in record it throws OnRecordErrorException .