本文整理汇总了Java中javax.jdo.Query.closeAll方法的典型用法代码示例。如果您正苦于以下问题:Java Query.closeAll方法的具体用法?Java Query.closeAll怎么用?Java Query.closeAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jdo.Query
的用法示例。
在下文中一共展示了Query.closeAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMaterialByName
import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public List<IMaterial> getMaterialByName(Long domainId, String materialName) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(Material.class);
query.setFilter("dId.contains(domainIdParam) && uName == unameParam");
query.declareParameters("Long domainIdParam, String unameParam");
List<IMaterial> results = null;
try {
results = (List<IMaterial>) query.execute(domainId, materialName);
if (results != null) {
results = (List<IMaterial>) pm.detachCopyAll(results);
}
} catch (Exception e) {
xLogger.warn("Error while fetching materials with name {0}", materialName, e);
} finally {
try {
query.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
pm.close();
}
return results;
}
示例2: getInventoryTransactionsByTrackingId
import javax.jdo.Query; //导入方法依赖的package包/类
/**
* Get inventory transactions by tracking-id
*/
@SuppressWarnings("unchecked")
public Results getInventoryTransactionsByTrackingId(Long trackingId) throws ServiceException {
xLogger.fine("Entered getInventoryTransactionsByTrackingId");
List<ITransaction> trans = null;
// Get PM
PersistenceManager pm = PMF.get().getPersistenceManager();
Query q = pm.newQuery(JDOUtils.getImplClass(ITransaction.class));
q.setFilter("tid == tidParam");
q.declareParameters("Long tidParam");
try {
trans = (List<ITransaction>) q.execute(trackingId);
trans = (List<ITransaction>) pm.detachCopyAll(trans);
trans.size();
} finally {
try {
q.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
pm.close();
}
Results r = new Results(trans, null);
xLogger.fine("Exiting getInventoryTransactionsByTrackingId");
return r;
}
示例3: fetchMinMaxLog
import javax.jdo.Query; //导入方法依赖的package包/类
/**
* Fetch the List<IInventoryMinMaxLog> for a given inventoryId
*/
public List<IInventoryMinMaxLog> fetchMinMaxLog(String invId) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = null;
List<IInventoryMinMaxLog> logs = null;
try {
String sqlQuery = "SELECT * FROM INVENTORYMINMAXLOG WHERE invId =? ORDER BY T DESC limit 50";
query = pm.newQuery("javax.jdo.query.SQL", sqlQuery);
query.setClass(JDOUtils.getImplClass(IInventoryMinMaxLog.class));
logs = (List<IInventoryMinMaxLog>) query.executeWithArray(invId);
logs = (List<IInventoryMinMaxLog>) pm.detachCopyAll(logs);
} catch (Exception e) {
xLogger.warn("Exception {0} when getting InvntryItem for invId {1}. Message: {2}",
e.getClass().getName(), invId, e.getMessage());
return null;
} finally {
if (query != null) {
query.closeAll();
}
pm.close();
}
return logs;
}
示例4: getMultiple
import javax.jdo.Query; //导入方法依赖的package包/类
/**
* Helper method to execute a JDO query in SQL and JQL.
* @param qp
* @param pm
* @param pageParams
* @return
*/
public static <T> List<T> getMultiple(QueryParams qp, PersistenceManager pm,
PageParams pageParams){
List<T> results = null;
Query q = getQuery(qp, pm, pageParams);
try {
results = (List<T>) getResults(qp, q);
if(results != null){
results = (List<T>) pm.detachCopyAll(results);
}
} finally {
q.closeAll();
}
return results;
}
示例5: getStateSuggestions
import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public List<LocationSuggestionModel> getStateSuggestions(Long domainId, String text) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = null;
List<LocationSuggestionModel> states = new ArrayList<>(8);
try {
query =
pm.newQuery("javax.jdo.query.SQL",
"SELECT DISTINCT COUNTRY,STATE FROM KIOSK WHERE STATE COLLATE UTF8_GENERAL_CI LIKE '%" + text + "%' AND KIOSKID IN " +
"( SELECT KIOSKID_OID FROM KIOSK_DOMAINS WHERE DOMAIN_ID=" + domainId
+ ") LIMIT 8");
List stateList = (List) query.execute();
for (Object st : stateList) {
String country = (String)((Object[])st)[0];
String state = (String)((Object[])st)[1];
LocationSuggestionModel model = new LocationSuggestionModel();
model.label = state;
model.country = country;
states.add(model);
}
return states;
} catch (Exception e) {
xLogger.severe("Error while fetching state suggestions from domain {0}", domainId, e);
} finally {
if (query != null) {
try {
query.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
}
pm.close();
}
return null;
}
示例6: getUsersByIds
import javax.jdo.Query; //导入方法依赖的package包/类
/**
* Method to fetch the user account details for the given userIds
*
* @param userIds User Id list
* @return List<IUserAccount>
*/
public List<IUserAccount> getUsersByIds(List<String> userIds) {
if (userIds == null || userIds.isEmpty()) {
return null;
}
List<IUserAccount> results = null;
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = null;
try {
StringBuilder queryBuilder = new StringBuilder("SELECT * FROM `USERACCOUNT` ");
queryBuilder.append("WHERE USERID IN (");
for (String userId : userIds) {
queryBuilder.append("'").append(userId).append("'").append(CharacterConstants.COMMA);
}
queryBuilder.setLength(queryBuilder.length() - 1);
queryBuilder.append(" )");
query = pm.newQuery("javax.jdo.query.SQL", queryBuilder.toString());
query.setClass(JDOUtils.getImplClass(IUserAccount.class));
results = (List<IUserAccount>) query.execute();
results = (List<IUserAccount>) pm.detachCopyAll(results);
} catch (Exception e) {
xLogger.warn("Exception while fetching approval status", e);
} finally {
if (query != null) {
try {
query.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
}
pm.close();
}
return results;
}
示例7: getAllMaterialsIds
import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public List<Long> getAllMaterialsIds(Long domainId) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = null;
List<Long> materialIds = new ArrayList<>(1);
try {
query =
pm.newQuery("javax.jdo.query.SQL",
"SELECT MATERIALID FROM MATERIAL M, MATERIAL_DOMAINS MD WHERE " +
"MD.MATERIALID_OID = M.MATERIALID AND MD.DOMAIN_ID=" + domainId);
List matIds = (List) query.execute();
for (Object matId : matIds) {
Long matIdL = (Long) matId;
if (matIdL != null) {
materialIds.add(matIdL);
}
}
return materialIds;
} catch (Exception e) {
xLogger.severe("Error while fetching material ids from domain {0} and query {1}", domainId,
query, e);
} finally {
if (query != null) {
try {
query.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
}
pm.close();
}
return null;
}
示例8: getHandlingUnitByName
import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public IHandlingUnit getHandlingUnitByName(Long domainId, String handlingUnitName)
throws ServiceException {
if (domainId == null || StringUtils.isEmpty(handlingUnitName)) {
throw new ServiceException("Invalid parameters");
}
IHandlingUnit hu = null;
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
// Form the query
Query huQuery = pm.newQuery(JDOUtils.getImplClass(IHandlingUnit.class));
huQuery.setFilter("dId.contains(dIdParam) && nName == nameParam");
huQuery.declareParameters("Long dIdParam, String nameParam");
try {
List<IHandlingUnit>
results =
(List<IHandlingUnit>) huQuery.execute(domainId, handlingUnitName.toLowerCase());
if (results != null && !results.isEmpty()) {
hu = results.get(0);
hu = pm.detachCopy(hu);
}
} finally {
huQuery.closeAll();
}
} catch (Exception e) {
xLogger.severe("Error while trying to get handling unit by name {0}", handlingUnitName, e);
} finally {
pm.close();
}
return hu;
}
示例9: createOrUpdateAssetRelation
import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public IAssetRelation createOrUpdateAssetRelation(Long domainId, IAssetRelation assetRelation)
throws ServiceException {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
Query query = pm.newQuery(JDOUtils.getImplClass(IAssetRelation.class));
query.setFilter("assetId == assetIdParam");
query.declareParameters("Long assetIdParam");
List<IAssetRelation> assetRelations = null;
try {
assetRelations = (List<IAssetRelation>) query.execute(assetRelation.getAssetId());
assetRelations = (List<IAssetRelation>) pm.detachCopyAll(assetRelations);
} catch (Exception ignored) {
//do nothing
} finally {
query.closeAll();
}
if (assetRelations != null && assetRelations.size() == 1) {
IAssetRelation assetRelationTmp = assetRelations.get(0);
assetRelationTmp.setRelatedAssetId(assetRelation.getRelatedAssetId());
assetRelationTmp.setType(assetRelation.getType());
pm.makePersistent(assetRelationTmp);
return assetRelationTmp;
} else {
pm.makePersistent(assetRelation);
EventPublisher.generate(domainId, IEvent.CREATED, null,
JDOUtils.getImplClassName(IAssetRelation.class), String.valueOf(assetRelation.getId()), null);
return assetRelation;
}
} catch (Exception e) {
xLogger.warn("{0} while updating asset relationship for the asset {1}", e.getMessage(),
assetRelation.getAssetId(), e);
throw new ServiceException(e.getMessage());
} finally {
pm.close();
}
}
示例10: getBatches
import javax.jdo.Query; //导入方法依赖的package包/类
public Results<IInvntryBatch> getBatches(Long materialId, Long kioskId, PageParams pageParams)
throws ServiceException {
PersistenceManager pm = PMF.get().getPersistenceManager();
String
queryStr =
"SELECT FROM " + JDOUtils.getImplClass(IInvntryBatch.class).getName()
+ " WHERE mId == mIdParam && kId == kIdParam && q > 0 PARAMETERS Long mIdParam, Long kIdParam ORDER BY bexp ASC";
Query q = pm.newQuery(queryStr);
if (pageParams != null) {
QueryUtil.setPageParams(q, pageParams);
}
Map<String, Object> params = new HashMap<>();
params.put("mIdParam", materialId);
params.put("kIdParam", kioskId);
xLogger.fine("Params: {0}", params);
List<IInvntryBatch> results = null;
String cursor = null;
try {
results = (List<IInvntryBatch>) q.executeWithMap(params);
xLogger.fine("Results: {0}", results);
if (results != null) {
results.size();
cursor = QueryUtil.getCursor(results);
results = (List<IInvntryBatch>) pm.detachCopyAll(results);
}
} finally {
try {
q.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
pm.close();
}
return new Results<>(results, cursor);
}
示例11: getHandlingUnitDataByMaterialId
import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public Map<String, String> getHandlingUnitDataByMaterialId(Long materialId) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = null;
try {
query =
pm.newQuery("javax.jdo.query.SQL",
"SELECT ID,(SELECT NAME FROM HANDLINGUNIT WHERE ID=HU_ID_OID) NAME, QUANTITY, HU_ID_OID FROM HANDLINGUNITCONTENT HUC WHERE HUC.TY = '0' AND HUC.CNTID = ?");
List data = (List) query.executeWithArray(materialId);
if (data == null || data.size() == 0) {
return null;
}
Map<String, String> huMap = new HashMap<>(3);
Object[] o = (Object[]) data.get(0);
huMap.put(IHandlingUnit.NAME, String.valueOf(o[1]));
huMap.put(IHandlingUnit.QUANTITY,
new BigDecimal(String.valueOf(o[2])).stripTrailingZeros().toPlainString());
huMap.put(IHandlingUnit.HUID, String.valueOf(o[3]));
return huMap;
} finally {
if (query != null) {
try {
query.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
}
pm.close();
}
}
示例12: getMessageById
import javax.jdo.Query; //导入方法依赖的package包/类
public IMessage getMessageById(String messageId) throws ServiceException {
IMessage message = null;
PersistenceManager pm = null;
Query query = null;
try {
pm = PMF.get().getPersistenceManager();
query = pm.newQuery(JDOUtils.getImplClass(IMessage.class));
query.setFilter("messageId == :messageIdParam");
Map<String, String> paramValues = new HashMap<>();
paramValues.put("messageIdParam", messageId);
query.setUnique(true);
message = (IMessage) query.executeWithMap(paramValues);
message = pm.detachCopy(message);
} catch (Exception e) {
xLogger.severe("{0} while getting message {1}", e.getMessage(), messageId, e);
throw new ServiceException(e);
} finally {
if (query != null) {
try {
query.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
}
if (pm != null) {
pm.close();
}
}
return message;
}
示例13: getModelSuggestion
import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public List<String> getModelSuggestion(Long domainId, String term) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = null;
try {
StringBuilder sqlQuery = new StringBuilder("SELECT DISTINCT MODEL FROM ASSET WHERE");
sqlQuery.append(" ID IN (SELECT ID_OID FROM ASSET_DOMAINS WHERE DOMAIN_ID = ")
.append(domainId).append(")");
if (StringUtils.isNotEmpty(term)) {
sqlQuery.append(" AND lower(MODEL) like '%").append(term.toLowerCase()).append("%'");
}
sqlQuery.append(" LIMIT 0, 10");
query = pm.newQuery("javax.jdo.query.SQL", sqlQuery.toString());
List modelList = (List) query.execute();
List<String> models = new ArrayList<>(modelList.size());
for (Object o : modelList) {
models.add((String) o);
}
return models;
} catch (Exception e) {
xLogger.warn("Error while fetching suggestions for asset models", e);
} finally {
if(query != null) {
query.closeAll();
}
pm.close();
}
return null;
}
示例14: getMigratoryOrders
import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public List<IOrder> getMigratoryOrders(Integer offset, Integer size, String cutoffDate) {
PersistenceManager pm = null;
Query query = null;
List<IOrder> retlist = null;
List<String> params = new ArrayList<>();
try {
String
squery =
" SELECT * FROM logistimo.ORDER ord LEFT JOIN logistimo.ORDER_JOB_STATUS ojs ON (ord.ID = ojs.ID) "
+
" WHERE ord.CON <= ? AND ojs.STATUS NOT IN ('COMPLETED','FAILED') OR ojs.STATUS is null "
+
" ORDER BY ord.ID ASC limit " + offset + CharacterConstants.COMMA + size;
params.add(cutoffDate);
pm = PMF.get().getPersistenceManager();
query = pm.newQuery("javax.jdo.query.SQL", squery);
query.setClass(Order.class);
retlist = (List<IOrder>) query.executeWithArray(params.toArray());
retlist = (List<IOrder>) pm.detachCopyAll(retlist);
} catch (Exception e) {
xlogger.warn("Error encountered during order migrations", e);
} finally {
if (query != null) {
query.closeAll();
}
if (pm != null) {
pm.close();
}
}
return retlist;
}
示例15: getLogs
import javax.jdo.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static Results getLogs(Long domainId, PageParams pageParams)
throws MessageHandlingException {
xLogger.fine("Entered getLogs");
if (domainId == null) {
throw new MessageHandlingException("No domainId specified");
}
List<IMessageLog> mlogs = null;
String cursor = null;
Map<String, Object> params = new HashMap<>();
PersistenceManager pm = PMF.get().getPersistenceManager();
Query q = pm.newQuery(JDOUtils.getImplClass(IMessageLog.class));
q.setFilter("dId == dIdParam && notif == notifParam");
q.declareParameters("Long dIdParam , Integer notifParam");
params.put("dIdParam", domainId);
params.put("notifParam", 0);
q.setOrdering("t desc");
if (pageParams != null) {
QueryUtil.setPageParams(q, pageParams);
}
try {
mlogs = (List<IMessageLog>) q.executeWithMap(params);
if (mlogs != null) {
mlogs.size(); // TODO: to ensure all objects are retrieved before closing object manager
cursor = QueryUtil.getCursor(mlogs);
mlogs = (List<IMessageLog>) pm.detachCopyAll(mlogs);
mlogs = sortByTime(mlogs);
}
} finally {
try {
q.closeAll();
} catch (Exception ignored) {
}
pm.close();
}
return new Results(mlogs, cursor);
}