2012-05-02 75 views
0

我orm.xml中爲我命名本機查詢,刪除查詢(命名原生查詢)不JPA工作與Hibernate規範

<named-native-query name="deleteAuthTokenByToken"> 
    <query><![CDATA[DELETE FROM AUTH_TOKEN WHERE TOKEN=:token]]></query> 
</named-native-query> 

我想在我的代碼爲

來執行這個查詢
em.getTransaction().begin(); 
em.createNamedQuery("deleteAuthTokenByToken").setParameter("token", token).executeUpdate(); 
em.getTransaction().commit(); 

實體管理器本身沒有創造,當我有orm.xml中查詢,得到的異常

Caused by: org.hibernate.cfg.NotYetImplementedException: Pure native scalar queries are not yet supported 

但同樣q下方uery工作,當我使用createNativeQuery()

回答

0

結果類是缺少這裏,這是我曾經改爲

<named-native-query name="deleteAuthTokenByTokenAndOrgId" result-class="com.modria.jpa.DO.AuthToken"> 
    <query><![CDATA[DELETE FROM AUTH_TOKEN WHERE TOKEN=:token AND ORG_ID=:orgId]]></query> 
</named-native-query> 
解決