我有一个像

  @Entity
    @Table(name = "ebooking")
    public class EBooking {

        @Id
        @Column(name = "bookId")
        private String bookId;


我实现了存储库llike

public interface EBookingRepository extends JpaRepository<EBooking, String>, JpaSpecificationExecutor<EBooking> {

    @Query("select book from EBooking book where book.bookId = :id")
    EBooking getByBookId(@Param("id") String id);
}


当我尝试运行此方法时,出现异常:

org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet

org.postgresql.util.PSQLException: ERROR: column ebooking0_.book_id does not exist
  Position: 8


为什么ebooking0_.book_id?只有ebooking表。

谢谢!

最佳答案

ebooking0_是Hibernate生成的ebooking表的别名。您可以检查是否打开了SQL日志记录。

错误确实表明您在表book_id中没有列ebooking

关于java - 无法提取ResultSet,列不存在,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30237589/

10-10 01:07