我试图逐行从数据库中删除特定的记录。但是当我试图执行这个查询时:
Query query = em.createQuery(
"DELETE FROM User u WHERE u.userId = :u");
query.setParameter("u", userID).executeUpdate();我得到了一个异常:“条件=不支持行键上的查询!”。
有什么解决办法吗,还是我漏掉了什么?
发布于 2012-07-26 12:02:35
作为一个解决办法,你可以做的是:
查找使用: User u= em.find(User.class,userId)
然后,em.delete(u);
发布于 2012-07-26 13:13:54
此外,http://groups.google.com/group/kundera-discuss/subscribe可以为您提供快速和更好的支持,以讨论昆德拉周围的问题。
-Vivek
发布于 2013-06-24 21:47:50
执行这种删除的一种可能方法(目前在使用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();https://stackoverflow.com/questions/11522120
复制相似问题