https://blog.csdn.net/weixin_43770545/article/details/89707718?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-1.pc_relevant_default&spm=1001.2101.3001.4242.2&utm_relevant_index=4
@Override public List<TrainingAllListVo> getAllTrainings(long teacherId, SchoolYear schoolYear, RegistrationStatus registrationStatus, EvaluationStatus evaluationStatus, String projectName,Integer page,Integer size) { String sql="SELECT project1_.id AS projectId,schedule0_.id as scheduleId, project1_.flage,project1_.project_name,project1_.school_year,schedule0_.schedule_name,schedule0_.schedule_begin_time,\n" + "schedule0_.schedule_end_time,project1_.training_form,grades6_.appraisal_scores,grades6_.actual_credits,schedulete4_.registration_status,school3_.school_name,organizati2_.organization_name,courses9_.course_status,notice10_.notice_status,leaves7_.check_status,evaluation8_.evaluation_status,evaluation8_.study_evaluation_status,notice10_.notice_path FROM SCHEDULE schedule0_ LEFT OUTER JOIN project project1_ ON schedule0_.project_id = project1_.id LEFT OUTER JOIN organization organizati2_ ON project1_.organization_id = organizati2_.id LEFT OUTER JOIN school school3_ ON project1_.school_id = school3_.id LEFT OUTER JOIN schedule_teacher schedulete4_ ON schedule0_.id = schedulete4_.schedule_id LEFT OUTER JOIN teacher teacher5_ ON schedulete4_.teacher_id = teacher5_.id LEFT OUTER JOIN grade grades6_ ON teacher5_.id = grades6_.teacher_id LEFT OUTER JOIN LEAVES leaves7_ ON teacher5_.id = leaves7_.teacher_id LEFT OUTER JOIN evaluation evaluation8_ ON schedule0_.id = evaluation8_.schedule_id LEFT OUTER JOIN course courses9_ ON schedule0_.id = courses9_.schedule_id LEFT OUTER JOIN notice notice10_ ON schedule0_.notice_id = notice10_.id WHERE schedulete4_.teacher_id ="+teacherId+" and if('"+schoolYear+"'!='null',project1_.school_year='"+schoolYear+"',1=1) and if('"+registrationStatus+"'!='null',schedulete4_.registration_status='"+registrationStatus+"',1=1) and if('"+evaluationStatus+"'!='null',evaluation8_.evaluation_status='"+evaluationStatus+"',1=1) and if('"+projectName+"'!='null',project1_.project_name LIKE CONCAT('%','"+projectName+"','%'),1=1) ORDER BY schedule0_.id DESC limit "+page+","+size+""; Query query=entityManager.createNativeQuery(sql); query.unwrap(SQLQuery.class).setResultTransformer(Transformers.aliasToBean(TrainingAllListVo.class)); return query.getResultList(); }