0
  • 最佳答案

    我把查询语句改成这样就解决了。。也能查出来数据了,这点小问题折腾了好久,希望大家以我为鉴!

    @Query(value = "SELECT student_id studentId,student_name studentName,student_class studentClass ,student_telephone studentTelephone ," +
            "training.training_id  trainingId,training_name trainingName " +
            "FROM student, training " +
            "WHERE student.training_id = training.training_id and training.jiaowu_id = :jiaowuId",nativeQuery = true)
    Page<List<Map<String,Object>>> listallWithoutpassword(Integer jiaowuId,Pageable pageable);
    
    1273975359737458688  评论     打赏       蜡笔小旧
    • gdf

      1275977651143602176  评论     打赏       亲爱的猴哥9
      • gdf

        1275977651143602176  评论     打赏       亲爱的猴哥9
        • fsfdsf

          1275977651143602176  评论     打赏       亲爱的猴哥9
          • qinhou

            1275977651143602176  评论     打赏       亲爱的猴哥9
            • liquinhuu

              1275977651143602176  评论     打赏       亲爱的猴哥9
              • gf

                1275977651143602176  评论     打赏       亲爱的猴哥9
                • 图二可能看不清,贴一下报错代码

                  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'

                  1273975359737458688  评论     打赏       蜡笔小旧
                  相关问题
                  你好,孙耀耀 · springboot / 摸鱼君
                  2022-07-25 11:32 52 4
                  2023-11-21 15:11 13 2