javax.jdo.Query.deletePersistentAll()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中javax.jdo.Query.deletePersistentAll方法的一些代码示例,展示了Query.deletePersistentAll的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.deletePersistentAll方法的具体详情如下:
包路径:javax.jdo.Query
类名称:Query
方法名:deletePersistentAll

Query.deletePersistentAll介绍

[英]Deletes all the instances of the candidate class that pass the filter. Returns the number of instances of the candidate class that were deleted, specifically not including the number of dependent and embedded instances.

Dirty instances of affected classes in the cache are first flushed to the datastore. Instances in the cache or brought into the cache as a result of executing one of the deletePersistentAll methods undergo life cycle changes as if deletePersistent were called on them.

Specifically, if the class of deleted instances implements the delete callback interface, the corresponding callback methods are called on the deleted instances. Similarly, if there are lifecycle listeners registered for delete events on affected classes, the listener is called for each appropriate deleted instance.

Before returning control to the application, instances of affected classes in the cache are refreshed to reflect whether they were deleted from the datastore.
[中]删除通过筛选的候选类的所有实例。返回已删除的候选类实例数,具体不包括依赖实例和嵌入实例数。
缓存中受影响类的脏实例首先被刷新到数据存储中。缓存中的实例或由于执行deletePersistentAll方法之一而带入缓存的实例会经历生命周期更改,就像对它们调用deletePersistent一样。
具体来说,如果已删除实例类实现了delete回调接口,则会对已删除实例调用相应的回调方法。类似地,如果有为受影响类上的删除事件注册的生命周期侦听器,则会为每个适当的已删除实例调用该侦听器。
在将控制权返回给应用程序之前,会刷新缓存中受影响类的实例,以反映它们是否已从数据存储中删除。

代码示例

代码示例来源:origin: apache/hive

private void dropPartitionAllColumnGrantsNoTxn(
  String catName, String dbName, String tableName, List<String> partNames) {
 ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(catName,
    dbName, tableName, partNames, MPartitionColumnPrivilege.class,
    "partition.table.tableName", "partition.table.database.name", "partition.partitionName",
    "partition.table.database.catalogName");
 queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
}

代码示例来源:origin: apache/hive

private void dropPartitionGrantsNoTxn(String catName, String dbName, String tableName,
                   List<String> partNames) {
 ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(catName,
    dbName, tableName, partNames,MPartitionPrivilege.class, "partition.table.tableName",
    "partition.table.database.name", "partition.partitionName",
    "partition.table.database.catalogName");
 queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
}

代码示例来源:origin: apache/hive

private void dropPartitionColumnStatisticsNoTxn(
  String catName, String dbName, String tableName, List<String> partNames) throws MetaException {
 ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(
   catName, dbName, tableName, partNames, MPartitionColumnStatistics.class,
   "tableName", "dbName", "partition.partitionName", "catName");
 queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
}

代码示例来源:origin: apache/hive

private void dropPartitionsNoTxn(String catName, String dbName, String tblName, List<String> partNames) {
 ObjectPair<Query, Map<String, String>> queryWithParams =
   getPartQueryWithParams(catName, dbName, tblName, partNames);
 Query query = queryWithParams.getFirst();
 query.setClass(MPartition.class);
 long deleted = query.deletePersistentAll(queryWithParams.getSecond());
 LOG.debug("Deleted {} partition from store", deleted);
 query.closeAll();
}

代码示例来源:origin: apache/hive

@Override
public int deleteRuntimeStats(int maxRetainSecs) throws MetaException {
 if (maxRetainSecs < 0) {
  LOG.warn("runtime stats retention is disabled");
  return 0;
 }
 boolean committed = false;
 try {
  openTransaction();
  int maxCreateTime = (int) (System.currentTimeMillis() / 1000) - maxRetainSecs;
  Query q = pm.newQuery(MRuntimeStat.class);
  q.setFilter("createTime <= maxCreateTime");
  q.declareParameters("int maxCreateTime");
  long deleted = q.deletePersistentAll(maxCreateTime);
  committed = commitTransaction();
  return (int) deleted;
 } finally {
  if (!committed) {
   rollbackTransaction();
  }
 }
}

代码示例来源:origin: apache/hive

@Override
public long cleanupEvents() {
 boolean commited = false;
 Query query = null;
 long delCnt;
 LOG.debug("Begin executing cleanupEvents");
 Long expiryTime =
   MetastoreConf.getTimeVar(getConf(), ConfVars.EVENT_EXPIRY_DURATION, TimeUnit.MILLISECONDS);
 Long curTime = System.currentTimeMillis();
 try {
  openTransaction();
  query = pm.newQuery(MPartitionEvent.class, "curTime - eventTime > expiryTime");
  query.declareParameters("java.lang.Long curTime, java.lang.Long expiryTime");
  delCnt = query.deletePersistentAll(curTime, expiryTime);
  commited = commitTransaction();
 } finally {
  rollbackAndCleanup(commited, query);
  LOG.debug("Done executing cleanupEvents");
 }
 return delCnt;
}

代码示例来源:origin: apache/hive

@Override
public void dropWMMapping(WMMapping mapping)
  throws NoSuchObjectException, InvalidOperationException, MetaException {
 String entityType = mapping.getEntityType().trim().toUpperCase();
 String entityName = normalizeIdentifier(mapping.getEntityName());
 boolean commited = false;
 Query query = null;
 try {
  openTransaction();
  MWMResourcePlan resourcePlan = getMWMResourcePlan(
    mapping.getResourcePlanName(), mapping.getNs(), true);
  query = pm.newQuery(MWMMapping.class,
    "resourcePlan == rp && entityType == type && entityName == name");
  query.declareParameters("MWMResourcePlan rp, java.lang.String type, java.lang.String name");
  if (query.deletePersistentAll(resourcePlan, entityType, entityName) != 1) {
   throw new NoSuchObjectException("Cannot delete mapping.");
  }
  commited = commitTransaction();
 } finally {
  rollbackAndCleanup(commited, query);
 }
}

代码示例来源:origin: apache/hive

@Override
public void dropWMTrigger(String resourcePlanName, String triggerName, String ns)
  throws NoSuchObjectException, InvalidOperationException, MetaException  {
 resourcePlanName = normalizeIdentifier(resourcePlanName);
 triggerName = normalizeIdentifier(triggerName);
 boolean commited = false;
 Query query = null;
 try {
  openTransaction();
  MWMResourcePlan resourcePlan = getMWMResourcePlan(resourcePlanName, ns, true);
  query = pm.newQuery(MWMTrigger.class, "resourcePlan == rp && name == triggerName");
  query.declareParameters("MWMResourcePlan rp, java.lang.String triggerName");
  if (query.deletePersistentAll(resourcePlan, triggerName) != 1) {
   throw new NoSuchObjectException("Cannot delete trigger: " + triggerName);
  }
  commited = commitTransaction();
 } finally {
  rollbackAndCleanup(commited, query);
 }
}

代码示例来源:origin: apache/hive

if (query.deletePersistentAll(resourcePlan, poolPath) != 1) {
 throw new NoSuchObjectException("Cannot delete pool: " + poolPath);

代码示例来源:origin: apache/sentry

@VisibleForTesting
 void clearAllTables() throws Exception {
  delegate.getTransactionManager().executeTransaction(
      pm -> {
       pm.newQuery(MSentryRole.class).deletePersistentAll();
       pm.newQuery(MSentryGroup.class).deletePersistentAll();
       pm.newQuery(MSentryGMPrivilege.class).deletePersistentAll();
       return null;
      });
 }
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

private void dropPartitionGrantsNoTxn(String dbName, String tableName, List<String> partNames) {
 ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(
    dbName, tableName, partNames,MPartitionPrivilege.class, "partition.table.tableName",
    "partition.table.database.name", "partition.partitionName");
 queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
}

代码示例来源:origin: org.spark-project.hive/hive-metastore

public void dropPartitionAllColumnGrantsNoTxn(
  String dbName, String tableName, List<String> partNames) {
 ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(
    dbName, tableName, partNames, MPartitionColumnPrivilege.class,
    "partition.table.tableName", "partition.table.database.name", "partition.partitionName");
 queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
}

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

private void dropPartitionAllColumnGrantsNoTxn(
  String catName, String dbName, String tableName, List<String> partNames) {
 ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(catName,
    dbName, tableName, partNames, MPartitionColumnPrivilege.class,
    "partition.table.tableName", "partition.table.database.name", "partition.partitionName",
    "partition.table.database.catalogName");
 queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
}

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

private void dropPartitionGrantsNoTxn(String catName, String dbName, String tableName,
                   List<String> partNames) {
 ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(catName,
    dbName, tableName, partNames,MPartitionPrivilege.class, "partition.table.tableName",
    "partition.table.database.name", "partition.partitionName",
    "partition.table.database.catalogName");
 queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
}

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

private void dropPartitionColumnStatisticsNoTxn(
  String catName, String dbName, String tableName, List<String> partNames) throws MetaException {
 ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(
   catName, dbName, tableName, partNames, MPartitionColumnStatistics.class,
   "tableName", "dbName", "partition.partitionName", "catName");
 queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

public void dropPartitionAllColumnGrantsNoTxn(
  String dbName, String tableName, List<String> partNames) {
 ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(
    dbName, tableName, partNames, MPartitionColumnPrivilege.class,
    "partition.table.tableName", "partition.table.database.name", "partition.partitionName");
 queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
}

代码示例来源:origin: org.spark-project.hive/hive-metastore

private void dropPartitionsNoTxn(String dbName, String tblName, List<String> partNames) {
 ObjectPair<Query, Map<String, String>> queryWithParams =
   getPartQueryWithParams(dbName, tblName, partNames);
 Query query = queryWithParams.getFirst();
 query.setClass(MPartition.class);
 long deleted = query.deletePersistentAll(queryWithParams.getSecond());
 LOG.debug("Deleted " + deleted + " partition from store");
 query.closeAll();
}

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

private void dropPartitionsNoTxn(String catName, String dbName, String tblName, List<String> partNames) {
 ObjectPair<Query, Map<String, String>> queryWithParams =
   getPartQueryWithParams(catName, dbName, tblName, partNames);
 Query query = queryWithParams.getFirst();
 query.setClass(MPartition.class);
 long deleted = query.deletePersistentAll(queryWithParams.getSecond());
 LOG.debug("Deleted {} partition from store", deleted);
 query.closeAll();
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

private void dropPartitionsNoTxn(String dbName, String tblName, List<String> partNames) {
 ObjectPair<Query, Map<String, String>> queryWithParams =
   getPartQueryWithParams(dbName, tblName, partNames);
 Query query = queryWithParams.getFirst();
 query.setClass(MPartition.class);
 long deleted = query.deletePersistentAll(queryWithParams.getSecond());
 LOG.debug("Deleted " + deleted + " partition from store");
 query.closeAll();
}

代码示例来源:origin: tzaeschke/zoodb

@After
public void afterTest() {
  TestTools.closePM();
  PersistenceManager pm = TestTools.openPM();
  pm.currentTransaction().begin();
  pm.newQuery(TestClassTiny2.class).deletePersistentAll();
  pm.newQuery(TestClassTiny.class).deletePersistentAll();
  pm.currentTransaction().commit();
  TestTools.closePM();
}

相关文章