项目场景:
项目用到了jpa多表联查加上动态查询
问题描述:
由于之前没接触过jpa项目,所以使用的的是原生sql语句开发,这个这个多表联查查询出来的数据是以数组的形式显示出来的,前边并没有属性,前端传不过去。
这个是之前代码。
@Query(value = "SELECT b.student_class as student_class," +
"a.activiteName as activiteName," +
"a.templateId as templateId," +
"a.student_answer as student_answer," +
"a.state as state," +
"a.student_id as student_id ," +
"b.student_name as student_name," +
"c.question as question," +
"a.start_time as start_time," +
"a.updata_time as updata_time," +
"a.is_delete as is_delete FROM test1 a left JOIN test2 b on a.student_id = b.studentID left JOIN test3 c on c.id = a.templateId WHERE a.is_delete = 0 " +
" and if(:student_class = '' or :student_class is null ,1=1,student_class like %:student_class%)" +
"and if(:activiteName = '' or :activiteName is null ,1=1,activiteName like %:activiteName%)" +
"and if(:templateId = '' or :templateId is null ,1=1,templateId =:templateId)" +
"and if(:student_answer = '' or :student_answer is null ,1=1,student_answer like %:student_answer%)" +
"and if(:state = '' or :state is null ,1=1,state like %:state%)" +
"and if(:student_id = '' or :student_id is null ,1=1,student_id =:student_id)" +
"and if(:student_name = '' or :student_name is null ,1=