我有像
这样的实体 @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
表。
谢谢!
答案 0 :(得分:1)
ebooking0_
是Hibernate生成的ebooking
表的别名。如果打开SQL日志记录,可以检查它。
错误确实表明您在表book_id
中没有列ebooking
。