Buggy code:
public class VirtuosoHarvestScriptDAO extends VirtuosoBaseDAO implements HarvestScriptDAO { private static final String LIST_SQL = "select<seq2seq4repair_space>*<seq2seq4repair_space>from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>where<seq2seq4repair_space>" + ( "coalesce(TARGET_SOURCE_URL,'')=?<seq2seq4repair_space>and<seq2seq4repair_space>coalesce(TARGET_TYPE_URL,'')=?<seq2seq4repair_space>and<seq2seq4repair_space>PHASE=coalesce(?,PHASE)<seq2seq4repair_space>" + "order<seq2seq4repair_space>by<seq2seq4repair_space>POSITION_NUMBER<seq2seq4repair_space>asc" ) ; private static final String LIST_ACTIVE_SQL = "select<seq2seq4repair_space>*<seq2seq4repair_space>from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>where<seq2seq4repair_space>" + ( "coalesce(TARGET_SOURCE_URL,'')=?<seq2seq4repair_space>and<seq2seq4repair_space>coalesce(TARGET_TYPE_URL,'')=?<seq2seq4repair_space>and<seq2seq4repair_space>PHASE=coalesce(?,PHASE)<seq2seq4repair_space>and<seq2seq4repair_space>ACTIVE='Y'<seq2seq4repair_space>" + "order<seq2seq4repair_space>by<seq2seq4repair_space>POSITION_NUMBER<seq2seq4repair_space>asc" ) ; private static final String LIST_ACTIVE_FOR_TYPES_SQL = "select<seq2seq4repair_space>*<seq2seq4repair_space>from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>where<seq2seq4repair_space>" + ( "TARGET_SOURCE_URL<seq2seq4repair_space>is<seq2seq4repair_space>null<seq2seq4repair_space>and<seq2seq4repair_space>TARGET_TYPE_URL<seq2seq4repair_space>in<seq2seq4repair_space>(@types@)<seq2seq4repair_space>and<seq2seq4repair_space>PHASE=coalesce(?,PHASE)<seq2seq4repair_space>and<seq2seq4repair_space>ACTIVE='Y'<seq2seq4repair_space>" + "order<seq2seq4repair_space>by<seq2seq4repair_space>TARGET_TYPE_URL<seq2seq4repair_space>asc,<seq2seq4repair_space>POSITION_NUMBER<seq2seq4repair_space>asc" ) ; private static final String SAVE_SQL = "update<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>" + "set<seq2seq4repair_space>TITLE=?,<seq2seq4repair_space>SCRIPT=?,<seq2seq4repair_space>ACTIVE=?,<seq2seq4repair_space>RUN_ONCE=?,<seq2seq4repair_space>PHASE=?,<seq2seq4repair_space>LAST_MODIFIED=NOW()<seq2seq4repair_space>where<seq2seq4repair_space>POST_HARVEST_SCRIPT_ID=?" ; private static final String DELETE_SQL = "delete<seq2seq4repair_space>from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>where<seq2seq4repair_space>POST_HARVEST_SCRIPT_ID=?" ; private static final String GET_LAST_POSITION_SQL = "select<seq2seq4repair_space>max(POSITION_NUMBER)<seq2seq4repair_space>as<seq2seq4repair_space>MAX_POS<seq2seq4repair_space>from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>where<seq2seq4repair_space>" + "coalesce(TARGET_SOURCE_URL,'')=?<seq2seq4repair_space>and<seq2seq4repair_space>coalesce(TARGET_TYPE_URL,'')=?" ; private static final String INSERT_SQL = "insert<seq2seq4repair_space>into<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>" + ( "(TARGET_SOURCE_URL,TARGET_TYPE_URL,TITLE,SCRIPT,POSITION_NUMBER,ACTIVE,RUN_ONCE,PHASE,LAST_MODIFIED)<seq2seq4repair_space>values<seq2seq4repair_space>" + "(?,?,?,?,?,?,?,?,NOW())" ) ; private static final String FETCH_SQL = "select<seq2seq4repair_space>*<seq2seq4repair_space>from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>where<seq2seq4repair_space>POST_HARVEST_SCRIPT_ID=?" ; private static final String LIST_TARGETS_SQL = "select<seq2seq4repair_space>coalesce(TARGET_SOURCE_URL,TARGET_TYPE_URL)<seq2seq4repair_space>as<seq2seq4repair_space>LCOL,<seq2seq4repair_space>count(*)<seq2seq4repair_space>as<seq2seq4repair_space>RCOL<seq2seq4repair_space>" + ( ( "from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>" + "where<seq2seq4repair_space>isnull(TARGET_SOURCE_URL)=?<seq2seq4repair_space>and<seq2seq4repair_space>isnull(TARGET_TYPE_URL)=?<seq2seq4repair_space>" ) + "group<seq2seq4repair_space>by<seq2seq4repair_space>LCOL<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>LCOL" ) ; private static final String ACTIVATE_DEACTIVATE_SQL = "update<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>set<seq2seq4repair_space>ACTIVE=either(starts_with(ACTIVE,'Y'),'N','Y')<seq2seq4repair_space>where<seq2seq4repair_space>POST_HARVEST_SCRIPT_ID=?" ; private static final String GET_POSITIONS_SQL = "select<seq2seq4repair_space>cast(POST_HARVEST_SCRIPT_ID<seq2seq4repair_space>as<seq2seq4repair_space>varchar)<seq2seq4repair_space>as<seq2seq4repair_space>LCOL,<seq2seq4repair_space>" + ( "cast(POSITION_NUMBER<seq2seq4repair_space>as<seq2seq4repair_space>varchar)<seq2seq4repair_space>as<seq2seq4repair_space>RCOL<seq2seq4repair_space>from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>" + "where<seq2seq4repair_space>coalesce(TARGET_SOURCE_URL,'')=?<seq2seq4repair_space>and<seq2seq4repair_space>coalesce(TARGET_TYPE_URL,'')=?<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>RCOL<seq2seq4repair_space>asc" ) ; private static final String UPDATE_POSITION_SQL = "update<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>set<seq2seq4repair_space>POSITION_NUMBER=?<seq2seq4repair_space>where<seq2seq4repair_space>POST_HARVEST_SCRIPT_ID=?" ; private static final String INCREASE_POSITIONS_SQL = "update<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>set<seq2seq4repair_space>POSITION_NUMBER=POSITION_NUMBER+?<seq2seq4repair_space>" + "where<seq2seq4repair_space>coalesce(TARGET_SOURCE_URL,'')=?<seq2seq4repair_space>and<seq2seq4repair_space>coalesce(TARGET_TYPE_URL,'')=?" ; private static final String EXISTS_SQL = "select<seq2seq4repair_space>count(*)<seq2seq4repair_space>from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>where<seq2seq4repair_space>" + "coalesce(TARGET_SOURCE_URL,'')=?<seq2seq4repair_space>and<seq2seq4repair_space>coalesce(TARGET_TYPE_URL,'')=?<seq2seq4repair_space>and<seq2seq4repair_space>TITLE=?" ; private static final String SEARCH_SQL = "select<seq2seq4repair_space>*<seq2seq4repair_space>from<seq2seq4repair_space>POST_HARVEST_SCRIPT<seq2seq4repair_space>where<seq2seq4repair_space>strcasestr(TITLE,?)<seq2seq4repair_space>>=<seq2seq4repair_space>0<seq2seq4repair_space>or<seq2seq4repair_space>strcasestr(SCRIPT,?)<seq2seq4repair_space>>=<seq2seq4repair_space>0<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>TITLE" ; @ Override public List < HarvestScriptDTO > list ( TargetType targetType , String targetUrl , Phase phase ) throws DAOException { } @ Override public List < HarvestScriptDTO > listActive ( TargetType targetType , String targetUrl , Phase phase ) throws DAOException { } @ Override public List < HarvestScriptDTO > listActiveForTypes ( List < String > types , Phase phase ) throws DAOException { if ( ( types == null ) || ( types . isEmpty ( ) ) ) { throw new IllegalArgumentException ( "Types<seq2seq4repair_space>must<seq2seq4repair_space>not<seq2seq4repair_space>be<seq2seq4repair_space>null<seq2seq4repair_space>or<seq2seq4repair_space>empty!" ) ; } StringBuilder questionMarks = new StringBuilder ( ) ; for ( int i = 0 ; i < ( types . size ( ) ) ; i ++ ) { questionMarks . append ( ( ( questionMarks . length ( ) ) == 0 ? "" : "," ) ) . append ( "?" ) ; } String sql = VirtuosoHarvestScriptDAO . LIST_ACTIVE_FOR_TYPES_SQL . replace ( "@types@" , questionMarks ) ; ArrayList < Object > values = new ArrayList < Object > ( ) ; values . addAll ( types ) ; <START_BUG> values . add ( phase ) ; <END_BUG> return executeSQL ( sql , values , new HarvestScriptDTOReader ( ) ) ; } @ Override public HarvestScriptDTO fetch ( int id ) throws DAOException { } @ Override public int insert ( TargetType targetType , String targetUrl , String title , String script , boolean active , boolean runOnce , Phase phase ) throws DAOException { } @ Override public void save ( int id , String title , String script , boolean active , boolean runOnce , Phase phase ) throws DAOException { } @ Override public void delete ( List < Integer > ids ) throws DAOException { } @ Override public void activateDeactivate ( List < Integer > ids ) throws DAOException { } @ Override public List < Pair < String , Integer > > listTargets ( TargetType targetType ) throws DAOException { } @ Override public void move ( TargetType targetType , String targetUrl , Set < Integer > ids , int direction ) throws DAOException { } @ Override public boolean exists ( TargetType targetType , String targetUrl , String title ) throws DAOException { } @ Override public List < Map < String , ObjectDTO > > test ( String query ) throws DAOException { } @ Override public List < Map < String , ObjectDTO > > test ( String constructQuery , TargetType targetType , String targetUrl , String harvestedSource ) throws DAOException { } @ Override public boolean isScriptsModified ( Date lastHarvestDate , String harvestSource ) throws DAOException { } @ Override public List < HarvestScriptDTO > getScriptsByIds ( List < Integer > ids ) throws DAOException { } @ Override public void addScripts ( TargetType targetType , String targetUrl , List < HarvestScriptDTO > scripts ) throws DAOException { } @ Override public List < HarvestScriptDTO > search ( String searchText ) throws DAOException { } }

Fix:
values . add ( ( phase == null ? null : phase . name ( ) ) ) ;