JPQL @Query - 无法准备语句异常
JPQL @Query - Could not prepare statement exception
当我尝试执行此 JPQL 时:
@Query("SELECT COUNT(v) FROM Vote v JOIN FETCH Restaurant WHERE v.restaurant.id=?1" )
Integer getVoteCountByRestaurantId(int id);
我有这个例外
nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement"
我试着改成
@Query("SELECT COUNT(v.id) FROM Vote v JOIN FETCH Restaurant WHERE v.restaurant.id=?1" )
但是异常是一样的,我哪里做错了?
试试这个:
@Query("SELECT COUNT(v.id) FROM Vote v JOIN v.restaurant r WHERE r.id=?1" )
当我尝试执行此 JPQL 时:
@Query("SELECT COUNT(v) FROM Vote v JOIN FETCH Restaurant WHERE v.restaurant.id=?1" )
Integer getVoteCountByRestaurantId(int id);
我有这个例外
nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement"
我试着改成
@Query("SELECT COUNT(v.id) FROM Vote v JOIN FETCH Restaurant WHERE v.restaurant.id=?1" )
但是异常是一样的,我哪里做错了?
试试这个:
@Query("SELECT COUNT(v.id) FROM Vote v JOIN v.restaurant r WHERE r.id=?1" )