Buggy code:
private static final String CHILD_ID ; private static final String AV_ISSUE_ID ; private static final String AV_OPTION_ID ; private static final String AV_USER_ID ; private SimpleDateFormat formatter ; private String searchWords ; private NumberKey [ ] textScope ; private String minId ; private String maxId ; private String minDate ; private String maxDate ; private int minVotes ; private NumberKey stateChangeAttributeId ; private NumberKey stateChangeFromOptionId ; private NumberKey stateChangeToOptionId ; private String stateChangeFromDate ; private String stateChangeToDate ; private NumberKey [ ] issueIdsFromTextSearch ; private List issueIdsFromUserSearch ; private NumberKey sortAttributeId ; private String sortPolarity ; public IssueSearch ( Issue issue ) throws Exception { } public IssueSearch ( Module module , IssueType issueType ) throws Exception { } public String getSearchWords ( ) { } public void setSearchWords ( String v ) { } public void setIssueIdsFromUserSearch ( List l ) { } public List getIssueIdsFromUserSearch ( ) { } public void setIssueIdsFromTextSearch ( NumberKey [ ] n ) { } public NumberKey [ ] getIssueIdsFromTextSearch ( ) { } public NumberKey [ ] getTextScope ( ) throws Exception { } private void setTextScopeToAll ( ) throws Exception { } public void setTextScope ( NumberKey [ ] v ) { } public String getMinId ( ) { } public void setMinId ( String v ) { } public String getMaxId ( ) { } public void setMaxId ( String v ) { } public String getMinDate ( ) { } public void setMinDate ( String v ) { } public String getMaxDate ( ) { } public void setMaxDate ( String v ) { } public int getMinVotes ( ) { } public void setMinVotes ( int v ) { } public NumberKey getStateChangeAttributeId ( ) { } public void setStateChangeAttributeId ( NumberKey v ) { } public NumberKey getStateChangeFromOptionId ( ) { } public void setStateChangeFromOptionId ( NumberKey v ) { } public NumberKey getStateChangeToOptionId ( ) { } public void setStateChangeToOptionId ( NumberKey v ) { } public String getStateChangeFromDate ( ) { } public void setStateChangeFromDate ( String v ) { } public String getStateChangeToDate ( ) { } public void setStateChangeToDate ( String v ) { } public NumberKey getSortAttributeId ( ) { } public void setSortAttributeId ( NumberKey v ) { } public String getSortPolarity ( ) { } public void setSortPolarity ( String v ) { } public NumberKey getALL_TEXT ( ) { } public List getQuickSearchTextAttributeValues ( ) throws Exception { } public List getTextAttributeValues ( ) throws Exception { } private List getTextAttributeValues ( boolean quickSearchOnly ) throws Exception { } public List getQuickSearchOptionAttributeValues ( ) throws Exception { } public List getOptionAttributeValues ( ) throws Exception { } private List getOptionAttributeValues ( boolean quickSearchOnly ) throws Exception { } private void removeUnsetValues ( List attValues ) { } private void addMinimumVotes ( Criteria crit ) throws ScarabException { } private void addIssueIdRange ( Criteria crit ) throws Exception , ScarabException { } private void combineUserAndTextCriteria ( Criteria crit ) throws ScarabException { } private void setDefaults ( FederatedId minFid , FederatedId maxFid ) throws Exception { } private void addCreatedDateRange ( Criteria crit ) throws Exception , ScarabException { } public Date parseDate ( String dateString , boolean addTwentyFourHours ) throws ParseException { } private Date parseDate ( String s , String [ ] patterns ) throws ParseException { } private void addDateRange ( String column , Date minUtilDate , Date maxUtilDate , Criteria crit ) throws ScarabException { } private void addSelectedAttributes ( Criteria crit , List attValues ) throws Exception { Criteria . Criterion c = null ; boolean atLeastOne = false ; HashMap aliasIndices = new HashMap ( ( ( int ) ( ( attValues . size ( ) ) * 1.25 ) ) ) ; for ( int j = 0 ; j < ( attValues . size ( ) ) ; j ++ ) { List chainedValues = ( ( AttributeValue ) ( attValues . get ( j ) ) ) . getValueList ( ) ; for ( int i = 0 ; i < ( chainedValues . size ( ) ) ; i ++ ) { AttributeValue aval = ( ( AttributeValue ) ( chainedValues . get ( i ) ) ) ; if ( aval instanceof OptionAttribute ) { atLeastOne = true ; Criteria . Criterion c2 = null ; String index = aval . getAttributeId ( ) . toString ( ) ; if ( aliasIndices . containsKey ( index ) ) { Criteria . Criterion prevCrit = ( ( Criteria . Criterion ) ( aliasIndices . get ( index ) ) ) ; c2 = buildOptionCriterion ( aval ) ; prevCrit . or ( c2 ) ; } else { <START_BUG> Criteria . Criterion c1 = crit . getNewCriterion ( ( "av" + index ) , IssueSearch . AV_ISSUE_ID , ( ( ( ( ( "av" + index ) + "." ) + ( IssueSearch . AV_ISSUE_ID ) ) + "=" ) + ( IssuePeer . ISSUE_ID ) ) , CUSTOM ) ; <END_BUG> crit . addAlias ( ( "av" + index ) , TABLE_NAME ) ; c2 = buildOptionCriterion ( aval ) ; c1 . and ( c2 ) ; aliasIndices . put ( index , c2 ) ; if ( c == null ) { c = c1 ; } else { c . and ( c1 ) ; } } } } } if ( atLeastOne ) { crit . add ( c ) ; } } private Criterion buildOptionCriterion ( AttributeValue aval ) throws Exception { } private NumberKey [ ] addTextMatches ( Criteria crit , List attValues ) throws Exception { } private void addStateChangeQuery ( Criteria crit ) throws Exception { } public List getMatchingIssues ( ) throws Exception { } private List sortIssues ( Criteria crit ) throws Exception { } private List sortByUniqueId ( Criteria crit ) throws Exception { } private List sortByAttribute ( Criteria crit ) throws Exception { } }

Fix:
Criteria . Criterion c1 = crit . getNewCriterion ( ( "av" + index ) , IssueSearch . AV_ISSUE_ID , ( ( ( ( ( "av" + index ) + '.' ) + ( IssueSearch . AV_ISSUE_ID ) ) + '=' ) + ( IssuePeer . ISSUE_ID ) ) , CUSTOM ) ;