使用JPA和Google App Engine更新查询 [英] Update query using JPA and Google App Engine

查看:99
本文介绍了使用JPA和Google App Engine更新查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  javax.persistence.PersistenceException:只能选择并支持删除语句。 

当我没有使用Google应用程序引擎时,此确切代码正常工作。
我的代码是:

  em.getTransaction()。begin(); 

查询查询=
em.createQuery(UPDATE Profile p+
SET p.age = 1+
WHERE p.email =:email );

query.setParameter(newPoint,point);
query.setParameter(email,email);

int updateCount = query.executeUpdate();
em.getTransaction()。commit();

所以我问我该如何更新实体查询?


由于GAE数据存储不支持直接更新数据存储中的字段的查询,因此您同样无法通过JPA API执行该操作。由于JPA从未设计用于其他类型的数据存储,因此您将看到不适用的功能。



通过查询检索对象,并手动更新它们。



当GAE提供完整的map-reduce开箱即用功能时,类似的东西可以支持

I'm trying to update my entity class, but I am getting :

javax.persistence.PersistenceException: Only select and delete statements are supported.

this exact code worked fine when i wasn't using Google app engine. My code is:

    em.getTransaction().begin();

    Query query =
            em.createQuery("UPDATE Profile p" +
                           "SET p.age = 1 " +
                           "WHERE p.email = :email" );

    query.setParameter("newPoint", point);
    query.setParameter("email", email);

    int updateCount = query.executeUpdate();        
    em.getTransaction().commit();

So I'm asking how can I update the entity query?

解决方案

Since the GAE datastore doesn't support a query that updates fields in the datastore directly, then you similarly cannot do that via the JPA API. Since JPA was never designed for other types of datastores then you will see features that are inapplicable.

Retrieve the objects via query, and update them manually.

When GAE provides full map-reduce out-of-the-box then something like that would be viable to support

这篇关于使用JPA和Google App Engine更新查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆