public void setTaskInstanceIndices ( Long taskInstId , Map < String , String > indices ) throws DataAccessException { try { db . openConnection ( ) ; // delete existing indices String query = "delete from INSTANCE_INDEX where INSTANCE_ID=? and OWNER_TYPE='TASK_INSTANCE'" ; // insert new ones db . runUpdate ( query , taskInstId ) ; query = "insert into INSTANCE_INDEX " + "(INSTANCE_ID,OWNER_TYPE,INDEX_KEY,INDEX_VALUE,CREATE_DT) values (?,'TASK_INSTANCE',?,?," + now ( ) + ")" ; db . prepareStatement ( query ) ; Object [ ] args = new Object [ 3 ] ; args [ 0 ] = taskInstId ; for ( String key : indices . keySet ( ) ) { args [ 1 ] = key ; args [ 2 ] = indices . get ( key ) ; if ( ! StringHelper . isEmpty ( ( String ) args [ 2 ] ) ) db . runUpdateWithPreparedStatement ( args ) ; } db . commit ( ) ; } catch ( Exception e ) { db . rollback ( ) ; throw new DataAccessException ( 0 , "failed to add task instance indices" , e ) ; } finally { db . closeConnection ( ) ; } }
new task instance indices