0
我正在使用dropwizard示例示例,並希望使用接受參數的sql查詢。Dropwizard @NamedQuery參數
這裏我Namedquery在我的用戶2類
@NamedQuery(
name = "com.example.helloworld.core.User2.name",
query = "SELECT p FROM User2 p where p.name = :name"
)
,並在我的User2Dao類我有這樣的方法。
public List<User2> findRole(String x) {
return list(namedQuery("com.example.helloworld.core.User2.name").setString("role", x));
}
這裏我在我的資源類
@GET
@Path("/{id}")
public List<User2> getUser(@PathParam("id") String id) {
return userDAO.findRole(id);
}
nethod我得到這個錯誤。
org.hibernate.HibernateException: No session currently bound to execution context
可以使用@NamedQuery來接受參數嗎?