我想從一個方法中做一個簡單的選擇計數語句,該方法適用於我的另一部分程序,但在這裏它給了我錯誤。java hibernate無法解析屬性
public Long validateSub(String source, String tbl){
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Query q = session.createQuery("SELECT count(s) from SlaveSubscribers s where s.SOURCENAME = :sourcename AND s.TBL = :tbl");
q.setParameter("sourcename", source);
q.setParameter("tbl", tbl);
Long result = (Long) q.list().get(0);
session.getTransaction().commit();
return result;
}
錯誤消息:
Exception in thread "Thread-3" org.hibernate.QueryException: could not resolve property: SOURCENAME of: com.datadistributor.main.SlaveSubscribers [SELECT count(s) from com.datadistributor.main.SlaveSubscribers s where s.SOURCENAME = :sourcename AND s.TBL = :tbl]
我不知道爲什麼這不起作用
請發佈一個提取您的類SlaveSubscribers(成員聲明和getter/setter for sourcename)和該類的hibernate映射文件(如果存在)。錯誤必須在那裏。 – Johanna 2012-03-15 07:54:52