2013-05-04 91 views
0

我想打一個getValueByLabel方法的簡單查詢:休眠 - 我的表沒有映射

這裏是我的代碼:

public Config getValueByLabel(String label) throws EntityPersistException{ 

    try { 
     Query query = em.createQuery("select id from config where config_label=:label",Long.class); 
     query.setParameter("label", label); 
     List<Long> config = query.getResultList(); 

     return em.getReference(Config.class, config.get(0)); 
    } 
... 

當我要開始我得到的方法:

org.hibernate.hql.internal.ast.QuerySyntaxException: config is not mapped [select id from config where config_label=:label] 

任何想法如何解決這個問題?

UPDATE

我使用:

休眠4.0.1.Final 和一個PostgreSQL數據庫1.16.1

回答

0

語法HQL是區分大小寫的。請查看查詢中使用的表/實體和列/實例變量名稱是否與對象相同。