Buggy code:
@ Repository public class ApplicationStatusDaoImpl extends AbstractBaseDaoImpl < ApplicationStatus > implements ApplicationStatusDao { public List < ApplicationStatusDTO > fetchAllApplicationByStatus ( final ApplicationStatusEnum applicationStatus ) throws ApplicationStatusException { } private void addScalar ( final SQLQuery query ) { } @ Override public void updateStatusByUserID ( final ApplicationStatusEnum status , final Long userId ) throws ApplicationStatusException { } @ Override public ApplicationStatus findUserByApplicationId ( final Long appId ) { } @ Override public List < PreEvaluatorConflictsDto > fetchPreEvalutorConflictsRecords ( final PaginationDataDTO paginationDataDTO , final PreEvaluatorConflictsDto dto , final Long evaluatorId ) { } @ Override public ApplicationStatusEnum fetchApplicationStatus ( final Long applicationUserId ) { } @ Override public List < ExpertConflictsDto > getExpertConflictsRecords ( final PaginationDataDTO paginationDataDTO , final ExpertConflictsDto dto , final Long evaluatorId ) { List < ExpertConflictsDto > dtoList = new ArrayList < ExpertConflictsDto > ( ) ; StringBuffer queryString = new StringBuffer ( ) ; int allRecordsCount = 0 ; queryString . append ( "Select<seq2seq4repair_space>a_s.id<seq2seq4repair_space>as<seq2seq4repair_space>applicationId,<seq2seq4repair_space>a_s.user_id<seq2seq4repair_space>as<seq2seq4repair_space>userid,<seq2seq4repair_space>u_d.first_name<seq2seq4repair_space>as<seq2seq4repair_space>firstName" ) ; queryString . append ( ",u_d.last_name<seq2seq4repair_space>as<seq2seq4repair_space>lastName,to_char(a_s.last_modified,'dd.mm.yyyy<seq2seq4repair_space>HH24:MI')<seq2seq4repair_space>as<seq2seq4repair_space>conflictDate" ) ; queryString . append ( ",max(individual_expert_rated_score)<seq2seq4repair_space>-<seq2seq4repair_space>min(individual_expert_rated_score)<seq2seq4repair_space>as<seq2seq4repair_space>scoreDifference" ) ; queryString . append ( "<seq2seq4repair_space>from<seq2seq4repair_space>application_status<seq2seq4repair_space>a_s" ) ; queryString . append ( "<seq2seq4repair_space>join<seq2seq4repair_space>application_assessment_trace<seq2seq4repair_space>a_a_t<seq2seq4repair_space>on<seq2seq4repair_space>a_a_t.application_id=<seq2seq4repair_space>a_s.id" ) ; queryString . append ( "<seq2seq4repair_space>join<seq2seq4repair_space>user_details<seq2seq4repair_space>u_d<seq2seq4repair_space>on<seq2seq4repair_space>u_d.id<seq2seq4repair_space>=<seq2seq4repair_space>a_s.user_id" ) ; queryString . append ( "<seq2seq4repair_space>where<seq2seq4repair_space>a_a_t.deleted<seq2seq4repair_space>=<seq2seq4repair_space>false<seq2seq4repair_space>and<seq2seq4repair_space>a_s.deleted<seq2seq4repair_space>=<seq2seq4repair_space>false<seq2seq4repair_space>and<seq2seq4repair_space>u_d.deleted<seq2seq4repair_space>=<seq2seq4repair_space>false" ) ; queryString . append ( "<seq2seq4repair_space>and<seq2seq4repair_space>a_s.status<seq2seq4repair_space>=<seq2seq4repair_space>'" ) . append ( EXPERT_CONFLICT ) . append ( "'" ) ; if ( ! ( GDEStringUtils . isNullOrEmpty ( dto . getSearchString ( ) ) ) ) { queryString . append ( ( ( "<seq2seq4repair_space>and<seq2seq4repair_space>(LOWER(u_d.first_name)<seq2seq4repair_space>like<seq2seq4repair_space>LOWER('%" + ( dto . getSearchString ( ) ) ) + "%')" ) ) ; queryString . append ( ( ( "<seq2seq4repair_space>or<seq2seq4repair_space>LOWER(u_d.last_name)<seq2seq4repair_space>like<seq2seq4repair_space>LOWER('%" + ( dto . getSearchString ( ) ) ) + "%')" ) ) ; queryString . append ( ( ( "<seq2seq4repair_space>or<seq2seq4repair_space>CAST(a_s.user_id<seq2seq4repair_space>AS<seq2seq4repair_space>TEXT)<seq2seq4repair_space>LIKE<seq2seq4repair_space>'%" + ( dto . getSearchString ( ) ) ) + "%'<seq2seq4repair_space>)" ) ) ; } queryString . append ( "<seq2seq4repair_space>group<seq2seq4repair_space>by<seq2seq4repair_space>a_s.id,<seq2seq4repair_space>a_s.user_id,<seq2seq4repair_space>u_d.first_name,<seq2seq4repair_space>u_d.last_name,<seq2seq4repair_space>a_s.last_modified" ) ; if ( ( ( paginationDataDTO . getSortProperty ( ) ) != null ) && ( ! ( paginationDataDTO . getSortProperty ( ) . trim ( ) . isEmpty ( ) ) ) ) { queryString . append ( "<seq2seq4repair_space>ORDER<seq2seq4repair_space>BY<seq2seq4repair_space>" ) ; queryString . append ( paginationDataDTO . getSortProperty ( ) ) ; if ( paginationDataDTO . getIsAscending ( ) ) { queryString . append ( "<seq2seq4repair_space>ASC" ) ; } else { queryString . append ( "<seq2seq4repair_space>DESC<seq2seq4repair_space>" ) ; } } SQLQuery query = getHibernateSession ( ) . createSQLQuery ( queryString . toString ( ) ) ; query . addScalar ( "applicationId" , LONG ) ; query . addScalar ( "userid" , LONG ) ; query . addScalar ( "firstName" , STRING ) ; query . addScalar ( "lastName" , STRING ) ; query . addScalar ( "conflictDate" , STRING ) ; <START_BUG> query . addScalar ( "scoreDifference" , INTEGER ) ; <END_BUG> dtoList = query . list ( ) ; if ( ( dtoList != null ) && ( ( dtoList . size ( ) ) > 0 ) ) { allRecordsCount = dtoList . size ( ) ; } paginationDataDTO . setAllRecordsCount ( allRecordsCount ) ; query . setFirstResult ( paginationDataDTO . getStartIndex ( ) ) ; query . setMaxResults ( paginationDataDTO . getTotalRecords ( ) ) ; query . setResultTransformer ( Transformers . aliasToBean ( ExpertConflictsDto . class ) ) ; dtoList = query . list ( ) ; return dtoList ; } }

Fix:
query . addScalar ( "scoreDifference" , DOUBLE ) ;