我正在尝试按行键从数据库中删除特定记录。但是当我尝试执行此查询时:
Query query = em.createQuery(
"DELETE FROM User u WHERE u.userId = :u");
query.setParameter("u", userID).executeUpdate();
我遇到了这个例外:“条件=不支持查询行键!”。
有没有解决方法,或者我遗漏了什么?
答案 0 :(得分:2)
您可以采取的解决方法是:
查找使用: 用户u = em.find(User.class,userId)
然后, em.delete(U);
答案 1 :(得分:1)
另外, http://groups.google.com/group/kundera-discuss/subscribe 可以为您提供快速和更好的支持,以讨论昆德拉周围的问题。
-Vivek
答案 2 :(得分:1)
执行此类删除的可能方法(在目前使用Kundera的2.2版命令中)是使用“本机查询”,例如:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu");
EntityManager em = emf.createEntityManager();
// "table" is the table name (case sensitive) you name your table in Cassandra
String query = "delete from table where key = 'keyValue'";
// "TablePersistencyEntity" is the Kundera Persistency Entity (Class) for the "table"
Query q = em.createNativeQuery(query, TablePersistencyEntity.class);
q.getResultList();
em.close();