Buggy code:
@ Repository @ Transactional ( propagation = Propagation . SUPPORTS , readOnly = true ) public class HibernateDao { @ Resource protected SessionFactory sessionFactory ; public SessionFactory getSessionFactory ( ) { } public void setSessionFactory ( SessionFactory sessionFactory ) { } public Session getSession ( ) { } public < T > T get ( T entity ) { } public < T , K extends Serializable > T get ( Class < T > entityClass , K id ) { } public < T > List < T > getAll ( Class < T > entityClass ) { } public < T , K extends Serializable > List < T > getByIds ( Class < T > entityClass , List < K > ids ) { } public < T > List < T > getByProperties ( Class < T > entityClass , Map < String , Object > properties ) { } @ Transactional public void delete ( Object entity ) { } @ Transactional public < K extends Serializable > void delete ( Class entityClass , K id ) { } @ Transactional public < T > T save ( T entity ) { } @ Transactional public < T > void save ( List < T > entities ) { } public List < Map < String , ? > > sqlQuery ( String sql , Object ... parameters ) { } public < T > List < T > sqlQuery ( Class < T > beanClass , String sql , Object ... parameters ) { } public List hqlQuery ( String hql , Object ... parameters ) { } public Page < Map < String , ? > > sqlPageQuery ( Page page , String sql , Object ... parameters ) { } public < T > Page < T > sqlPageQuery ( Page < T > page , Class < T > beanClass , String sql , Object ... parameters ) { } public Page hqlPageQuery ( Page page , String hql , Object ... parameters ) { } public static < T > Page < T > pageQuery ( Query query , Page < T > page ) { } public Map < String , ? > sqlUniqueQuery ( String sql , Object ... parameters ) { } public < T > T sqlUniqueQuery ( Class < T > beanClass , String sql , Object ... parameters ) { } public Object hqlUniqueQuery ( String hql , Object ... parameters ) { } public long countSql ( String sql , Object ... parameters ) { } public long countHql ( String hql , Object ... parameters ) { <START_BUG> String countHql = "SELECT<seq2seq4repair_space>COUNT(1)<seq2seq4repair_space>" + hql ; <END_BUG> Number number = ( ( Number ) ( hqlUniqueQuery ( countHql , parameters ) ) ) ; return number . longValue ( ) ; } public SQLQuery createSQLQuery ( String sql , Object ... parameters ) { } public Query createQuery ( String hql , Object ... parameters ) { } public < T > Criteria createCriteria ( Class < T > entityClass ) { } @ Transactional public int execute ( String sql , Object ... parameters ) { } @ Transactional public void executeBatch ( final String ... sqlList ) { } @ Transactional public void executeBatch ( final String sql , final Object [ ] [ ] parameters ) { } public < T extends Query > T setParameters ( T query , Object ... parameters ) { } protected boolean isSimple ( Object value ) { } private SQLQuery setQueryType ( SQLQuery query , Class beanClass ) { } private static Map namedParameters ( Map map ) { } private static Class getEntityClass ( Object entity ) { } private ClassMetadata getClassMetadata ( Class entityClass ) { } private static Object handle ( Object value ) { } protected static final Set < Class > simpleTypes = new HashSet < Class > ( Arrays . asList ( boolean . class , byte . class , double . class , float . class , int . class , long . class , short . class , Boolean . class , Byte . class , Double . class , Float . class , Integer . class , Long . class , Short . class , String . class , BigDecimal . class , BigInteger . class , Number . class , Date . class , Time . class , Timestamp . class , Blob . class , Clob . class , InputStream . class , Reader . class , Ref . class , SQLXML . class , URL . class , Class . class ) ) ; }

Fix:
String countHql = "SELECT<seq2seq4repair_space>COUNT(*)<seq2seq4repair_space>" + hql ;