当前位置: 首页>>代码示例>>Java>>正文


Java PersistenceManager.newQuery方法代码示例

本文整理汇总了Java中javax.jdo.PersistenceManager.newQuery方法的典型用法代码示例。如果您正苦于以下问题:Java PersistenceManager.newQuery方法的具体用法?Java PersistenceManager.newQuery怎么用?Java PersistenceManager.newQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jdo.PersistenceManager的用法示例。


在下文中一共展示了PersistenceManager.newQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInvTotalCount

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public Integer getInvTotalCount(Map<String, String> filter) throws SQLException{
  PersistenceManager pm = PMF.get().getPersistenceManager();
  StringBuilder
      sb =
      new StringBuilder("SELECT COUNT(1) AS COUNT FROM INVNTRY WHERE KID = " + Long.parseLong(
          filter.get(Constants.ENTITY)));
  if (filter.get(Constants.MATERIAL_TAG) != null) {
    sb.append(
        " AND MID IN (SELECT MATERIALID FROM MATERIAL_TAGS WHERE ID IN (SELECT ID FROM TAG WHERE NAME IN (")
        .append(String.valueOf(filter.get(Constants.MATERIAL_TAG))).append(")))");
  }
  Query query = pm.newQuery("javax.jdo.query.SQL",sb.toString());
  query.setUnique(true);
  Object object = query.execute();
  Integer count = ((Long) object).intValue();
  return count;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:18,代码来源:DashboardService.java

示例2: getFilteredRequesters

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public Collection<String> getFilteredRequesters(String requester, Long domainId) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query query = null;
  List<String> queryList = new ArrayList<>(0);
  try {
    if (StringUtils.isNotEmpty(requester)) {
      query = pm.newQuery("javax.jdo.query.SQL",
          "SELECT DISTINCT CREATED_BY FROM ORDER_APPROVAL_MAPPING WHERE "
              + "EXISTS (SELECT 1 from USERACCOUNT_DOMAINS WHERE CREATED_BY = USERID_OID "
              + "AND DOMAIN_ID = ?) "
              + "AND CREATED_BY in (SELECT USERID from USERACCOUNT WHERE NNAME like ?) limit 10");
      List results = (List) query.executeWithArray(domainId, requester.toLowerCase() + "%");
      if(results != null && !results.isEmpty()) {
        queryList = new ArrayList<>(results.size());
        for(Object o : results) {
          queryList.add((String)o);
        }
      }
    }
  } finally {
    if (query != null) {
      query.closeAll();
    }
    pm.close();
  }
  return queryList;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:28,代码来源:ApprovalsDao.java

示例3: getOutOfStockCounts

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public int getOutOfStockCounts(Long entityId) {
  int count = 0;
  PersistenceManager pm = null;
  Query query = null;
  try {
    pm = PMF.get().getPersistenceManager();
    Map<String, Object> params = new HashMap<String, Object>(1);
    query =
        pm.newQuery("select key from " + JDOUtils.getImplClass(IInvntry.class).getName()
            + " where kId == kIdParam && stk == 0f PARAMETERS Long kIdParam");
    params.put("kIdParam", entityId);
    List<Long> results = (List<Long>) query.executeWithMap(params);
    if (results != null) {
      count = results.size();
    }
  } catch (Exception e) {
    xLogger.warn("Failed to get out of stock counts for Entity: {0}", entityId, e);
  } finally {
    if (query != null) {
      try {
        query.closeAll();
      } catch (Exception ignored) {
        xLogger.warn("Exception while closing query", ignored);
      }
    }
    if (pm != null) {
      pm.close();
    }
  }
  return count;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:34,代码来源:InventoryManagementServiceImpl.java

示例4: getInvMaterialCount

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
/**
 * Method to get the count of unique materials for a given domain id
 *
 * @param domainId Domain Id
 * @return Count of unique materials
 */
public Long getInvMaterialCount(Long domainId, Long tagId) throws ServiceException {
  if (domainId == null) {
    return 0L;
  }
  StringBuilder
      queryBuilder =
      new StringBuilder(
          "SELECT COUNT(DISTINCT(MID)) FROM INVNTRY WHERE KID IN (SELECT KIOSKID_OID FROM KIOSK_DOMAINS WHERE DOMAIN_ID=?)");
  Long count;
  try {
    List<String> parameters = new ArrayList<>(2);
    PersistenceManager pm = PMF.get().getPersistenceManager();
    Query query;
    if (tagId != null) {
      queryBuilder.append(" AND MID IN (SELECT MATERIALID FROM MATERIAL_TAGS WHERE ID=?)");
      parameters.add(String.valueOf(tagId));
    }
    query = pm.newQuery("javax.jdo.query.SQL", queryBuilder.toString());
    parameters.add(String.valueOf(domainId));
    query.setUnique(true);
    count = (Long) query.executeWithArray(parameters.toArray());
  } catch (Exception e) {
    xLogger.warn("Exception fetching the count", e);
    throw new ServiceException("Failed to fetch count");
  }
  return count;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:34,代码来源:InventoryManagementServiceImpl.java

示例5: findAllPoolGroups

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
/**
 * Find all pool groups with pagination, in a given domain
 * TODO: Pagination
 */
@SuppressWarnings("unchecked")
public List<IPoolGroup> findAllPoolGroups(Long domainId, int pageNumber, int numOfEntries) {
  xLogger.fine("Entering findAllPooLGroups");
  PersistenceManager pm = PMF.get().getPersistenceManager();
  List<IPoolGroup> poolGroups = new ArrayList<IPoolGroup>();

  // Formulate query
  Query query = pm.newQuery(JDOUtils.getImplClass(IPoolGroup.class));
  query.setFilter("dId == domainIdParam");
  query.declareParameters("Long domainIdParam");
  query.setOrdering("name asc");
  // Execute query
  try {
    poolGroups = (List<IPoolGroup>) query.execute(domainId);
    poolGroups
        .size(); // TODO - temp. fix for retrieving all obejcts and avoid "object manager closed" exception
    poolGroups = (List<IPoolGroup>) pm.detachCopyAll(poolGroups);
  } catch (Exception e) {
    xLogger.warn("Exception: {0}", e.getMessage());
  } finally {
    try {
      query.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }

  xLogger.fine("Exiting findAllPooLGroups");
  return poolGroups;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:36,代码来源:EntitiesServiceImpl.java

示例6: getStateSuggestions

import javax.jdo.PersistenceManager; //导入方法依赖的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;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:36,代码来源:EntitiesServiceImpl.java

示例7: getValidBatches

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Results<IInvntryBatch> getValidBatches(Long materialId, Long kioskId, PageParams pageParams,
                                PersistenceManager pm) throws ServiceException {
  xLogger.fine("Entered getValidBatches");
  // Form query
  String
      queryStr =
      "SELECT FROM " + JDOUtils.getImplClass(IInvntryBatch.class).getName()
          + " WHERE mId == mIdParam && kId == kIdParam && vld == vldParam PARAMETERS Long mIdParam, Long kIdParam, Boolean vldParam 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);
  params.put("vldParam", Boolean.TRUE);
  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 {
    q.closeAll();
  }
  xLogger.fine("Exiting getValidBatches");
  return new Results<>(results, cursor);
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:35,代码来源:InventoryManagementServiceImpl.java

示例8: getMaterialByName

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
public IMaterial getMaterialByName(Long domainId, String materialName) throws ServiceException {
  xLogger.fine("Entering getMaterialByName");
  if (domainId == null || materialName == null || materialName.isEmpty()) {
    throw new ServiceException("Invalid parameters");
  }
  IMaterial m = null;
  // Form query
  PersistenceManager pm = PMF.get().getPersistenceManager();

  try {
    // Form the query
    Query materialQuery = pm.newQuery(JDOUtils.getImplClass(IMaterial.class));
    materialQuery.setFilter("dId.contains(dIdParam) && uName == nameParam");
    materialQuery.declareParameters("Long dIdParam, String nameParam");
    // Execute the query
    try {
      List<IMaterial>
          results =
          (List<IMaterial>) materialQuery.execute(domainId, materialName.toLowerCase());
      if (results != null && !results.isEmpty()) {
        m = results.get(0);
        m = pm.detachCopy(m);
      }
    } finally {
      materialQuery.closeAll();
    }

  } catch (Exception e) {
    xLogger.severe("{0} when trying to get Material for Material Name {1}. Message: {2}",
        e.getClass().getName(), materialName, e.getMessage());
  } finally {
    pm.close();
  }
  xLogger.fine("Exiting getMaterial");
  return m;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:38,代码来源:MaterialCatalogServiceImpl.java

示例9: getHandlingUnitByName

import javax.jdo.PersistenceManager; //导入方法依赖的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;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:32,代码来源:HandlingUnitServiceImpl.java

示例10: getOrderApprovalMapping

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public IOrderApprovalMapping getOrderApprovalMapping(Long orderId, Integer approvalType) {
  IOrderApprovalMapping orderApprovalMapping = null;
  List<IOrderApprovalMapping> results = null;
  if (orderId != null) {
    PersistenceManager pm = null;
    Query query = null;
    try {
      pm = PMF.get().getPersistenceManager();
      Map<String, Object> params = new HashMap<>();
      query = pm.newQuery(JDOUtils.getImplClass(IOrderApprovalMapping.class));
      query.setFilter("orderId == orderIdParam && approvalType == approvalTypeParam");
      query.declareParameters("Long orderIdParam, Integer approvalTypeParam");
      query.setOrdering("createdAt desc");
      query.setRange(0, 1);
      params.put(ORDER_ID_PARAM, orderId);
      params.put(APPROVAL_TYPE_PARAM, approvalType);
      results = (List<IOrderApprovalMapping>) query.executeWithMap(params);
      if (results != null && !results.isEmpty()) {
        orderApprovalMapping = results.get(0);
      }
    } catch (Exception e) {
      xLogger.warn("Failed to get order approval mapping for order: {0}",
          orderId, e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          xLogger.warn("Exception while closing query", ignored);
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
  }
  return orderApprovalMapping;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:39,代码来源:ApprovalsDao.java

示例11: customIdExists

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
/**
 * Check if a custom ID is available in a domain or it's child domains
 */
public boolean customIdExists(Long domainId, String customId, String userId)
    throws ServiceException {
  if (domainId == null || customId == null || customId.isEmpty() || userId == null || userId
      .isEmpty()) {
    throw new ServiceException("Invalid or null Domain ID: {0}, custom ID : {1}, user ID: {2}",
        domainId, customId, userId);
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query query = pm.newQuery(JDOUtils.getImplClass(IUserAccount.class));
  query.setFilter("dId.contains(domainIdParam) && cId == cidParam");
  query.declareParameters("Long domainIdParam, String cidParam");
  try {
    List<IUserAccount> results = (List<IUserAccount>) query.execute(domainId, customId);
    if (results != null && results.size() == 1) {
      if (userId != null) {
        IUserAccount res = results.get(0);
        if (userId.equals(res.getUserId())) {
          return false;
        }
      }
      return true;
    }
  } finally {
    try {
      query.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }
  return false;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:36,代码来源:UsersServiceImpl.java

示例12: getModelSuggestion

import javax.jdo.PersistenceManager; //导入方法依赖的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;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:30,代码来源:AssetManagementServiceImpl.java

示例13: getUploadMsgLog

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List<IUploadedMsgLog> getUploadMsgLog(String uploadedKey, PersistenceManager pm) {
  Query query = pm.newQuery(JDOUtils.getImplClass(IUploadedMsgLog.class));
  try {
    query.setFilter("uploadedId == uploadedIdParam");
    query.declareParameters("String uploadedIdParam");
    List<IUploadedMsgLog> results = (List<IUploadedMsgLog>) query.execute(uploadedKey);
    return (List<IUploadedMsgLog>) pm.detachCopyAll(results);
  } finally {
    if (query != null) {
      query.closeAll();
    }
  }

}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:16,代码来源:DaoUtil.java

示例14: testJdoSafeFilter2

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public void testJdoSafeFilter2(String filterValue) {
    PersistenceManager pm = getPM();
    Query q = pm.newQuery(UserEntity.class);
    q.setFilter("id == userId");
    q.declareParameters("int userId");

}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:8,代码来源:JdoSqlFilter.java

示例15: testJdoQueriesAdditionalMethodSig

import javax.jdo.PersistenceManager; //导入方法依赖的package包/类
public void testJdoQueriesAdditionalMethodSig(String input) {
    PersistenceManager pm = getPM();

    pm.newQuery(UserEntity.class,new ArrayList(),"id == "+ input); //Injection?

    pm.newQuery(UserEntity.class,new ArrayList(),"id == 1");

    pm.newQuery(UserEntity.class,"id == "+ input); //Injection?

    pm.newQuery(UserEntity.class,"id == 1");

    pm.newQuery((Extent) null,"id == "+input); //Injection?

    pm.newQuery((Extent) null,"id == 1");

}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:17,代码来源:JdoSql.java


注:本文中的javax.jdo.PersistenceManager.newQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。