【问题标题】:How can i clear my Google appengine Datastore using JPA QUERY?如何使用 JPA QUERY 清除我的 Google appengine 数据存储区?
【发布时间】:2011-10-28 10:57:33
【问题描述】:

Im trying to clear my datastore, dynamically in a servlet, using Jquery. but i cant find any API for clear all tables automatically, so im 试图从所有表中删除所有行,如下所示:

EntityManager em = emfInstance.createEntityManager();
em.getTransaction().begin();
String q = String.format("DELETE FROM " + className + " WHERE key IS NOT NULL");        
Query jquery = em.createQuery(q);
jquery.executeUpdate();
em.getTransaction().commit();

但我无法将键与 NULL 进行比较,除了 GAE 将 id 显示为仪表板上的 ID/名称,并将其称为代码中的键。

有谁知道如何清除所有数据存储?注意本地的,部署的!

提前致谢!

【问题讨论】:

    标签: google-app-engine jpa google-cloud-datastore jpql


    【解决方案1】:

    您可以轻松地使用 JPQL DELETE 来执行此操作

    Query q = em.createQuery("DELETE FROM MyClass m");
    q.executeUpdate();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-25
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      • 2010-11-12
      • 2015-04-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多