最近在跟着您的博客系统做一个实训管理项目,我想查出来学生的信息和学生所在的实训的信息,请问我在Dao层这么写查询为什么会报错呢?而且控制台输出的sql语句也很奇怪,莫名其妙出来了count()。把返回类型最外层的page去掉,就不会报错,一分页就报错。请问这是为什么?
实体类的结构和您的博客系统是差不多的,没有建立onetomany和manytoone那些联系,是我多表查询的方式不对吗?springboot纯小白请赐教
@Query(value = "SELECT student_id studentId,student_name studentName,student_class studentClass ,student_telephone studentTelephone ," +
"t.training_id trainingId,training_name trainingName " +
"FROM student s, training t " +
"WHERE s.training_id = t.training_id and t.training_id in (SELECT training_id from training WHERE jiaowu_id =:jiaowuId)",nativeQuery = true)
Page<List<Map<String,Object>>> listallWithoutpassword(Integer jiaowuId,Pageable pageable);
控制台打印的sql语句多出来的count,是因为分页的原因吗?

网页报错500

我把查询语句改成这样就解决了。。也能查出来数据了,这点小问题折腾了好久,希望大家以我为鉴!
gdf
gdf
fsfdsf
qinhou
liquinhuu
gf
图二可能看不清,贴一下报错代码
Hibernate:
SELECT
student_id studentId,
student_name studentName,
student_class studentClass ,
student_telephone studentTelephone ,
t.training_id trainingId,
training_name trainingName
FROM
student s,
training t
WHERE
s.training_id = t.training_id
and t.jiaowu_id = ? limit ?
Hibernate:
select
count(s)
FROM
student s,
training t
WHERE
s.training_id = t.training_id
and t.jiaowu_id = ?
[2020/06/25-03:17:16] [http-nio-8181-exec-2] [WARN ] [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] : SQL Error: 1054, SQLState: 42S22
[2020/06/25-03:17:16] [http-nio-8181-exec-2] [ERROR] [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] : Unknown column 's' in 'field list'
[2020/06/25-03:17:16] [http-nio-8181-exec-2] [ERROR] [org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet]] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
java.sql.SQLSyntaxErrorException: Unknown column 's' in 'field list'