无法提取的ResultSet,列不存在

问题描述:

我有一个像无法提取的ResultSet,列不存在

@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日志记录。

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

+0

你是对的!谢谢! – yazabara

+0

不客气。 –