Buggy code:
@ Repository ( "scheduleDao" ) public class ScheduleDaoHibernate extends GenericDaoHibernate < Schedule , Long > implements ScheduleDao { public ScheduleDaoHibernate ( ) { } @ Override public List < Schedule > getActivedSchedules ( String schoolId , String classInfoId , String classTypeId , String classBZId , String courseId , User user ) { } @ Override public List < Schedule > listSchedules ( String schoolId , String classInfoId , String classTypeId , String classBZId , String courseId ) { } private List < Schedule > listSchedules ( String schooldId , String classInfoId , String classTypeId , String classBZId , String courseId , User user , String status ) { } public List < Object [ ] > getSchedules2 ( String schoolId , String classInfoId , String classTypeId , String classBZId , String courseId , User user ) { } @ Override public int getCourseSwitchTimes2 ( Map < String , Object > params ) { } @ Override public int getCourseApplyTimes2 ( Map < String , Object > params ) { } @ Override public int getCourseApplyCancelTimes2 ( Map < String , Object > params ) { } @ Override public int getCourseCancelTimes2 ( Map < String , Object > params ) { } @ Override public List < Schedule > getSchedulesForSave ( String schooldId , String classInfoId , String classTypeId , String classBZId , String courseId ) { } @ Override public List < Object [ ] > searchSchedules ( String schoolId , String classInfoId , String classTypeId , String classBZId , String courseId , Timestamp start , Timestamp end , User user ) { } private List < Object [ ] > scheduleQuery ( String schoolId , String classInfoId , String classTypeId , String classBZId , String courseId , Timestamp start , Timestamp end , User user , String status ) { } @ Override public List < Object [ ] > getActiveSchedules ( String schoolId , String classInfoId , String classTypeId , String classBZId , String courseId , Timestamp start , Timestamp end , User user ) { } public List < Object [ ] > searchSelectCourses2 ( String schoolId , String classInfoId , String classTypeId , String classBZId , String courseId , Timestamp start , Timestamp end , User user ) { List < Object [ ] > list = new ArrayList < Object [ ] > ( ) ; String hql = "select<seq2seq4repair_space>cs.school_id,<seq2seq4repair_space>cs.classinfo_id,cs.classtype_id,cs.classbz_id,cs.course_id,count(distinct<seq2seq4repair_space>u.id)<seq2seq4repair_space>as<seq2seq4repair_space>count,min(cs.count)" + ( "<seq2seq4repair_space>FROM<seq2seq4repair_space>select_course<seq2seq4repair_space>sc,course_schedule<seq2seq4repair_space>cs,app_user<seq2seq4repair_space>u<seq2seq4repair_space>" + "<seq2seq4repair_space>where<seq2seq4repair_space>sc.student_id=u.id<seq2seq4repair_space>and<seq2seq4repair_space>sc.schedule_id=cs.id<seq2seq4repair_space>" ) ; <START_BUG> hql += "<seq2seq4repair_space>and<seq2seq4repair_space>sc.status<seq2seq4repair_space>!=<seq2seq4repair_space>-3<seq2seq4repair_space>and<seq2seq4repair_space>sc.status<seq2seq4repair_space>!=<seq2seq4repair_space>5<seq2seq4repair_space>and<seq2seq4repair_space>sc.status<seq2seq4repair_space>!=1<seq2seq4repair_space>" ; <END_BUG> if ( null != user ) { hql += "<seq2seq4repair_space>and<seq2seq4repair_space>sc.student_id<seq2seq4repair_space>=" + ( user . getId ( ) ) ; } if ( ( ( null != schoolId ) && ( ( schoolId . length ( ) ) > 0 ) ) && ( ! ( schoolId . equalsIgnoreCase ( "0" ) ) ) ) { hql += "<seq2seq4repair_space>and<seq2seq4repair_space>cs.school_id=" + ( Long . parseLong ( schoolId ) ) ; } if ( ( ( null != classInfoId ) && ( ( classInfoId . length ( ) ) > 0 ) ) && ( ! ( classInfoId . equalsIgnoreCase ( "0" ) ) ) ) { hql += "<seq2seq4repair_space>and<seq2seq4repair_space>cs.classInfo_id=" + ( Long . parseLong ( classInfoId ) ) ; } if ( ( ( null != classTypeId ) && ( ( classTypeId . length ( ) ) > 0 ) ) && ( ! ( classTypeId . equalsIgnoreCase ( "0" ) ) ) ) { hql += "<seq2seq4repair_space>and<seq2seq4repair_space>cs.classtype_id=" + ( Long . parseLong ( classTypeId ) ) ; } if ( ( ( null != classBZId ) && ( ( classBZId . length ( ) ) > 0 ) ) && ( ! ( classBZId . equalsIgnoreCase ( "0" ) ) ) ) { hql += "<seq2seq4repair_space>and<seq2seq4repair_space>cs.classBZ_id=" + ( Long . parseLong ( classBZId ) ) ; } if ( ( ( null != courseId ) && ( ( courseId . length ( ) ) > 0 ) ) && ( ! ( courseId . equalsIgnoreCase ( "0" ) ) ) ) { hql += "<seq2seq4repair_space>and<seq2seq4repair_space>cs.course_id=" + ( Long . parseLong ( courseId ) ) ; } if ( null != start ) { hql += ( "<seq2seq4repair_space>and<seq2seq4repair_space>cs.startTime<seq2seq4repair_space>>=<seq2seq4repair_space>'" + start ) + "'" ; } if ( null != end ) { hql += ( "<seq2seq4repair_space>and<seq2seq4repair_space>cs.endTime<seq2seq4repair_space><=<seq2seq4repair_space>'" + end ) + "'" ; } hql += "<seq2seq4repair_space>group<seq2seq4repair_space>by<seq2seq4repair_space>cs.school_id,<seq2seq4repair_space>cs.classinfo_id,cs.classtype_id,cs.classbz_id,cs.course_id" ; List < Object [ ] > result = getSession ( ) . createSQLQuery ( hql . toLowerCase ( ) ) . list ( ) ; return result ; } @ Override public List < SelectCourse > searchSelectCourses ( Map < String , Object > params , User user ) { } @ Override public List < Object [ ] > searchSelectCourseWrap ( Map < String , Object > params , User user ) { } @ Override public int searchSelectCourseWrapCount ( Map < String , Object > params , User user ) { } private String parseParameters ( Map < String , Object > params ) { } @ Override public List < SelectCourse > getAllSelectCourses ( Map < String , Object > params ) { } @ Override public List < SelectCourse > searchSelectCourseByLeader ( Map < String , Object > params , User user ) { } @ Override public int deleteSelectedCourse ( SelectCourse selectCourse , User user ) { } @ Override public List < SelectCourse > getSelectCourse ( String scheduleId , String userId ) { } @ Override public List < SelectCourse > getAllMyCourse ( String userId ) { } @ Override public List < Schedule > batchSaveSchedule ( List < Schedule > list ) { } @ Override public boolean batchRemoveSchedule ( List < Schedule > list ) { } @ Override public void saveSelectCourse ( SelectCourse selectCourse ) { } @ Override public void deleteSelectCourse ( SelectCourse selectCourse ) { } @ Override public void BatchSaveSelectCourse ( List < SelectCourse > selectCourses ) { } @ Override public List < SelectCourse > getSelectCouseForSchedule ( Schedule schedule ) { }

Fix:
hql += "<seq2seq4repair_space>and<seq2seq4repair_space>sc.status<seq2seq4repair_space>!=<seq2seq4repair_space>-3<seq2seq4repair_space>and<seq2seq4repair_space>sc.status<seq2seq4repair_space>!=<seq2seq4repair_space>5<seq2seq4repair_space>and<seq2seq4repair_space>sc.status<seq2seq4repair_space>!=1<seq2seq4repair_space>and<seq2seq4repair_space>sc.status!=-1<seq2seq4repair_space>and<seq2seq4repair_space>sc.status!=3<seq2seq4repair_space>" ;