我正在使用Spring開機和休眠的項目。我想計算表中的ID與記錄。我可以統計表中的所有記錄,但無法對外鍵計數記錄。如何計算特定ID在春季開機和休眠的記錄
這裏是我的控制器代碼
@RequestMapping("/rating/{id}")
@ResponseBody
public long getRatingInfo(@PathVariable("id") long id, HttpServletRequest req, HttpServletResponse res) throws Exception {
long postobj = myDao.count();
return postobj;
}
我在這裏通過在URL中id
但沒有的count
方法通過這個ID查找記錄。
這裏是我的DAO接口
@Transactional
public interface MyDaoInterface extends CrudRepository<Rating, Long>{
}
你想對給定'id'算rating'的'? – SWiggels
其實我在我的分貝有評級表。在這個表中,我有post_id,user_id和rating_points列。 post_id可以是多個,我想要計算給定的所有行post_id –