Buggy code:
@ Repository public class MessageDaoImpl extends AbstractBaseDaoImpl < GdeMessage > implements MessageDao { @ Override public final List < GdeMessage > findSentMessages ( final GdeUser user , final PaginationDataDTO paginationDataDTO ) throws MessageException { } @ SuppressWarnings ( "unchecked" ) @ Override public final List < MessageDto > findInboxMessages ( final GdeUser user , final PaginationDataDTO paginationDataDTO ) throws MessageException { StringBuffer queryString = new StringBuffer ( ) ; <START_BUG> queryString . append ( "Select<seq2seq4repair_space>{sender.*},<seq2seq4repair_space>message.id<seq2seq4repair_space>as<seq2seq4repair_space>messageId,<seq2seq4repair_space>message.creation_date<seq2seq4repair_space>as<seq2seq4repair_space>messageCreationDate," ) . append ( "<seq2seq4repair_space>message.parent_id<seq2seq4repair_space>as<seq2seq4repair_space>parentMessageId,<seq2seq4repair_space>message.subject<seq2seq4repair_space>as<seq2seq4repair_space>subject," ) . append ( "<seq2seq4repair_space>message.content<seq2seq4repair_space>as<seq2seq4repair_space>content,<seq2seq4repair_space>userStatus.is_read<seq2seq4repair_space>as<seq2seq4repair_space>read,<seq2seq4repair_space>userStatus.deleted<seq2seq4repair_space>as<seq2seq4repair_space>deleted" ) . append ( "<seq2seq4repair_space>from<seq2seq4repair_space>message<seq2seq4repair_space>inner<seq2seq4repair_space>join<seq2seq4repair_space>message_recipient<seq2seq4repair_space>recipient<seq2seq4repair_space>on<seq2seq4repair_space>recipient.message_id<seq2seq4repair_space>=<seq2seq4repair_space>message.id" ) . append ( "<seq2seq4repair_space>inner<seq2seq4repair_space>join<seq2seq4repair_space>user_details<seq2seq4repair_space>sender<seq2seq4repair_space>on<seq2seq4repair_space>message.created_by<seq2seq4repair_space>=<seq2seq4repair_space>sender.id<seq2seq4repair_space>" ) . append ( "<seq2seq4repair_space>left<seq2seq4repair_space>outer<seq2seq4repair_space>join<seq2seq4repair_space>message_user_status<seq2seq4repair_space>userStatus<seq2seq4repair_space>on<seq2seq4repair_space>userStatus.message_id<seq2seq4repair_space>=<seq2seq4repair_space>message.id<seq2seq4repair_space>" ) . append ( "<seq2seq4repair_space>where<seq2seq4repair_space>recipient.recipient_id<seq2seq4repair_space>=<seq2seq4repair_space>" ) ; <END_BUG> queryString . append ( user . getId ( ) ) ; queryString . append ( "<seq2seq4repair_space>and<seq2seq4repair_space>message.deleted=false<seq2seq4repair_space>and<seq2seq4repair_space>userStatus.deleted<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>true" ) ; 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 . addEntity ( "sender" , GdeUser . class ) ; query . addScalar ( "messageId" , LONG ) ; query . addScalar ( "parentMessageId" , LONG ) ; query . addScalar ( "messageCreationDate" , TIMESTAMP ) ; query . addScalar ( "subject" , STRING ) ; query . addScalar ( "content" , STRING ) ; query . addScalar ( "read" , BOOLEAN ) ; query . addScalar ( "deleted" , BOOLEAN ) ; query . setFirstResult ( paginationDataDTO . getStartIndex ( ) ) ; query . setMaxResults ( paginationDataDTO . getTotalRecords ( ) ) ; query . setResultTransformer ( Transformers . aliasToBean ( MessageDto . class ) ) ; return query . list ( ) ; } @ SuppressWarnings ( "unchecked" ) @ Override public int getUserInboxCount ( final GdeUser user ) throws MessageException { } @ Override public int getUserSentMessagesCount ( final GdeUser user ) throws MessageException { } }

Fix:
queryString . append ( "Select<seq2seq4repair_space>{sender.*},<seq2seq4repair_space>message.id<seq2seq4repair_space>as<seq2seq4repair_space>messageId,<seq2seq4repair_space>message.creation_date<seq2seq4repair_space>as<seq2seq4repair_space>messageCreationDate," ) . append ( "<seq2seq4repair_space>message.parent_id<seq2seq4repair_space>as<seq2seq4repair_space>parentMessageId,<seq2seq4repair_space>message.subject<seq2seq4repair_space>as<seq2seq4repair_space>subject," ) . append ( "<seq2seq4repair_space>message.content<seq2seq4repair_space>as<seq2seq4repair_space>content,<seq2seq4repair_space>userStatus.is_read<seq2seq4repair_space>as<seq2seq4repair_space>read,<seq2seq4repair_space>userStatus.deleted<seq2seq4repair_space>as<seq2seq4repair_space>deleted" ) . append ( "<seq2seq4repair_space>from<seq2seq4repair_space>message<seq2seq4repair_space>inner<seq2seq4repair_space>join<seq2seq4repair_space>message_recipient<seq2seq4repair_space>recipient<seq2seq4repair_space>on<seq2seq4repair_space>recipient.message_id<seq2seq4repair_space>=<seq2seq4repair_space>message.id" ) . append ( "<seq2seq4repair_space>inner<seq2seq4repair_space>join<seq2seq4repair_space>user_details<seq2seq4repair_space>sender<seq2seq4repair_space>on<seq2seq4repair_space>message.created_by<seq2seq4repair_space>=<seq2seq4repair_space>sender.id<seq2seq4repair_space>" ) . append ( "<seq2seq4repair_space>left<seq2seq4repair_space>outer<seq2seq4repair_space>join<seq2seq4repair_space>message_user_status<seq2seq4repair_space>userStatus<seq2seq4repair_space>on<seq2seq4repair_space>userStatus.message_id<seq2seq4repair_space>=<seq2seq4repair_space>message.id<seq2seq4repair_space>and<seq2seq4repair_space>userStatus.user_id<seq2seq4repair_space>=<seq2seq4repair_space>recipient.recipient_id" ) . append ( "<seq2seq4repair_space>where<seq2seq4repair_space>recipient.recipient_id<seq2seq4repair_space>=<seq2seq4repair_space>" ) ;