本文整理了Java中javax.jdo.Query.setResult
方法的一些代码示例,展示了Query.setResult
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setResult
方法的具体详情如下:
包路径:javax.jdo.Query
类名称:Query
方法名:setResult
[英]Specifies what type of data this query should return. If this is unset or set to null
, this query returns instances of the query's candidate class. If set, this query will return expressions, including field values (projections) and aggregate function results.
[中]指定此查询应返回的数据类型。如果未设置或设置为null
,此查询将返回查询的候选类的实例。如果设置,此查询将返回表达式,包括字段值(投影)和聚合函数结果。
代码示例来源:origin: apache/hive
@Override
public List<String> listRoleNames() {
boolean success = false;
Query query = null;
try {
openTransaction();
LOG.debug("Executing listAllRoleNames");
query = pm.newQuery("select roleName from org.apache.hadoop.hive.metastore.model.MRole");
query.setResult("roleName");
Collection names = (Collection) query.execute();
List<String> roleNames = new ArrayList<>();
for (Iterator i = names.iterator(); i.hasNext();) {
roleNames.add((String) i.next());
}
success = commitTransaction();
return roleNames;
} finally {
rollbackAndCleanup(success, query);
}
}
代码示例来源:origin: apache/hive
query = pm.newQuery(MTable.class);
query.declareImports("import java.lang.String");
query.setResult("tableName");
query.setResultClass(java.lang.String.class);
if (maxTables >= 0) {
代码示例来源:origin: apache/hive
@Override
public List<String> getCatalogs() throws MetaException {
LOG.debug("Fetching all catalog names");
boolean commited = false;
List<String> catalogs = null;
String queryStr = "select name from org.apache.hadoop.hive.metastore.model.MCatalog";
Query query = null;
openTransaction();
try {
query = pm.newQuery(queryStr);
query.setResult("name");
catalogs = new ArrayList<>((Collection<String>) query.execute());
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
Collections.sort(catalogs);
return catalogs;
}
代码示例来源:origin: apache/hive
query.setResult("functionName");
query.setOrdering("functionName ascending");
Collection names = (Collection) query.executeWithArray(parameterVals.toArray(new String[parameterVals.size()]));
代码示例来源:origin: apache/hive
@Override
public List<String> getDatabases(String catName, String pattern) throws MetaException {
if (pattern == null || pattern.equals("*")) {
return getAllDatabases(catName);
}
boolean commited = false;
List<String> databases = null;
Query query = null;
try {
openTransaction();
// Take the pattern and split it on the | to get all the composing
// patterns
String[] subpatterns = pattern.trim().split("\\|");
StringBuilder filterBuilder = new StringBuilder();
List<String> parameterVals = new ArrayList<>(subpatterns.length);
appendSimpleCondition(filterBuilder, "catalogName", new String[] {catName}, parameterVals);
appendPatternCondition(filterBuilder, "name", subpatterns, parameterVals);
query = pm.newQuery(MDatabase.class, filterBuilder.toString());
query.setResult("name");
query.setOrdering("name ascending");
Collection<String> names = (Collection<String>) query.executeWithArray(parameterVals.toArray(new String[0]));
databases = new ArrayList<>(names);
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
return databases;
}
代码示例来源:origin: apache/hive
} else {
query.setResult(Joiner.on(',').join(fieldNames));
代码示例来源:origin: apache/hive
@Override
public List<String> getAllDatabases(String catName) throws MetaException {
boolean commited = false;
List<String> databases = null;
Query query = null;
catName = normalizeIdentifier(catName);
openTransaction();
try {
query = pm.newQuery("select name from org.apache.hadoop.hive.metastore.model.MDatabase " +
"where catalogName == catname");
query.declareParameters("java.lang.String catname");
query.setResult("name");
databases = new ArrayList<>((Collection<String>) query.execute(catName));
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
Collections.sort(databases);
return databases;
}
代码示例来源:origin: apache/hive
query.setOrdering("partitionName descending");
query.setResult("partitionName");
代码示例来源:origin: apache/hive
private List<String> getPartitionNamesNoTxn(String catName, String dbName, String tableName, short max) {
List<String> pns = new ArrayList<>();
if (max == 0) {
return pns;
}
catName = normalizeIdentifier(catName);
dbName = normalizeIdentifier(dbName);
tableName = normalizeIdentifier(tableName);
Query query =
pm.newQuery("select partitionName from org.apache.hadoop.hive.metastore.model.MPartition "
+ "where table.database.name == t1 && table.tableName == t2 && table.database.catalogName == t3 "
+ "order by partitionName asc");
query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3");
query.setResult("partitionName");
if (max > 0) {
query.setRange(0, max);
}
Collection<String> names = (Collection<String>) query.execute(dbName, tableName, catName);
pns.addAll(names);
if (query != null) {
query.closeAll();
}
return pns;
}
代码示例来源:origin: apache/hive
query.setResult("tableName");
query.setOrdering("tableName ascending");
Collection<String> names = (Collection<String>) query.executeWithArray(parameterVals.toArray(new String[0]));
代码示例来源:origin: apache/hive
private boolean constraintNameAlreadyExists(String name) {
boolean commited = false;
Query constraintExistsQuery = null;
String constraintNameIfExists = null;
try {
openTransaction();
name = normalizeIdentifier(name);
constraintExistsQuery = pm.newQuery(MConstraint.class, "constraintName == name");
constraintExistsQuery.declareParameters("java.lang.String name");
constraintExistsQuery.setUnique(true);
constraintExistsQuery.setResult("name");
constraintNameIfExists = (String) constraintExistsQuery.execute(name);
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, constraintExistsQuery);
}
return constraintNameIfExists != null && !constraintNameIfExists.isEmpty();
}
代码示例来源:origin: apache/hive
/**
* Detaches column descriptors from storage descriptors; returns the set of unique CDs
* thus detached. This is done before dropping partitions because CDs are reused between
* SDs; so, we remove the links to delete SDs and then check the returned CDs to see if
* they are referenced by other SDs.
*/
private HashSet<MColumnDescriptor> detachCdsFromSdsNoTxn(
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);
query.setResult("sd");
@SuppressWarnings("unchecked")
List<MStorageDescriptor> sds = (List<MStorageDescriptor>)query.executeWithMap(
queryWithParams.getSecond());
HashSet<MColumnDescriptor> candidateCds = new HashSet<>();
for (MStorageDescriptor sd : sds) {
if (sd != null && sd.getCD() != null) {
candidateCds.add(sd.getCD());
sd.setCD(null);
}
}
if (query != null) {
query.closeAll();
}
return candidateCds;
}
代码示例来源:origin: apache/hive
q.setResult(partValuesSelect.toString());
代码示例来源:origin: apache/hive
private boolean poolHasChildren(MWMResourcePlan resourcePlan, String poolPath) {
boolean commited = false;
Query query = null;
try {
openTransaction();
query = pm.newQuery(MWMPool.class, "resourcePlan == rp && path.startsWith(poolPath)");
query.declareParameters("MWMResourcePlan rp, java.lang.String poolPath");
query.setResult("count(this)");
query.setUnique(true);
Long count = (Long) query.execute(resourcePlan, poolPath + ".");
commited = commitTransaction();
return count != null && count > 0;
} finally {
rollbackAndCleanup(commited, query);
}
}
代码示例来源:origin: apache/hive
+ "&& this.table.tableName == t3");
query.declareParameters("String t1, String t2, String t3");
query.setResult("this.partitionName, this.sd.location");
if (max >= 0) {
代码示例来源:origin: apache/hive
dbExistsQuery.declareParameters("java.lang.String db, java.lang.String cat");
dbExistsQuery.setUnique(true);
dbExistsQuery.setResult("name");
String dbNameIfExists = (String) dbExistsQuery.execute(db, catName);
if (org.apache.commons.lang.StringUtils.isEmpty(dbNameIfExists)) {
代码示例来源:origin: apache/hive
@Override
public List<String> getMaterializedViewsForRewriting(String catName, String dbName)
throws MetaException, NoSuchObjectException {
final String db_name = normalizeIdentifier(dbName);
catName = normalizeIdentifier(catName);
boolean commited = false;
Query<?> query = null;
List<String> tbls = null;
try {
openTransaction();
dbName = normalizeIdentifier(dbName);
query = pm.newQuery(MTable.class,
"database.name == db && database.catalogName == cat && tableType == tt && rewriteEnabled == re");
query.declareParameters(
"java.lang.String db, java.lang.String cat, java.lang.String tt, boolean re");
query.setResult("tableName");
Collection<String> names = (Collection<String>) query.executeWithArray(
db_name, catName, TableType.MATERIALIZED_VIEW.toString(), true);
tbls = new ArrayList<>(names);
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
return tbls;
}
代码示例来源:origin: apache/hive
query.setResult(resultsCol);
代码示例来源:origin: anjuke/hwi
public Long getTotal() {
if (total == null) {
Query newQuery = query.getPersistenceManager().newQuery(query);
newQuery.setOrdering(null);
newQuery.setResult("COUNT(id)");
total = (Long) newQuery.executeWithMap(map);
}
return total;
}
代码示例来源:origin: tzaeschke/zoodb
private void checkSetResultFails(PersistenceManager pm, String s) {
Query q = pm.newQuery(TestClass.class);
q.setResult(s);
try {
q.execute();
fail();
} catch (JDOUserException e) {
//good, we got an JDOUSerException()
}
}
内容来源于网络,如有侵权,请联系作者删除!