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


Java Query.setClass方法代码示例

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


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

示例1: getShipmentsByOrderId

import javax.jdo.Query; //导入方法依赖的package包/类
/**
 * Get all shipment for a specific order
 *
 * @param orderId Order Id
 * @return -
 */
@Override
@SuppressWarnings("unchecked")
public List<IShipment> getShipmentsByOrderId(Long orderId, PersistenceManager pm) {
  Query query = null;
  try {
    query = pm.newQuery("javax.jdo.query.SQL", "SELECT * FROM SHIPMENT WHERE ORDERID = ?");
    query.setClass(JDOUtils.getImplClass(IShipment.class));
    List list = (List) query.executeWithArray(orderId);
    List<IShipment> shipments = new ArrayList<>(list.size());
    for (Object shipment : list) {
      shipments.add((IShipment) shipment);
    }
    return shipments;
  } catch (Exception e) {
    xLogger.severe("Error while fetching shipments by order id: {0}", orderId, e);
  } finally {
    if (query != null) {
      query.closeAll();
    }
  }
  return null;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:29,代码来源:ShipmentService.java

示例2: 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;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:28,代码来源:InventoryManagementServiceImpl.java

示例3: getQuery

import javax.jdo.Query; //导入方法依赖的package包/类
private static Query getQuery(QueryParams qp, PersistenceManager pm,
                              PageParams pageParams) {
  Query q;
  if (QueryParams.QTYPE.SQL.equals(qp.qType)) {
    String query = qp.query;
    if (query != null && pageParams != null && !query.contains(" LIMIT ")) {
      query +=
          " LIMIT " + pageParams.getOffset() + CharacterConstants.COMMA + pageParams
              .getSize();
    }
    q = pm.newQuery("javax.jdo.query.SQL", query);
    q.setClass(JDOUtils.getImplClass(qp.qClazz));
  } else {
    q = pm.newQuery(qp.query);
    if (pageParams != null) {
      QueryUtil.setPageParams(q, pageParams);
    }
  }
  return q;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:21,代码来源:JDOUtils.java

示例4: searchMaterialsNoHU

import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public Results searchMaterialsNoHU(Long domainId, String q) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query query = null;
  try {
    query =
        pm.newQuery("javax.jdo.query.SQL",
            "SELECT * FROM MATERIAL M, MATERIAL_DOMAINS MD WHERE MD.MATERIALID_OID = M.MATERIALID AND MD.DOMAIN_ID="
                + domainId +
                " AND UNAME LIKE '" + q.toLowerCase()
                + "%' AND NOT EXISTS(SELECT 1 FROM HANDLINGUNITCONTENT WHERE CNTID = MATERIALID AND TY=0) LIMIT 8");
    query.setClass(Material.class);
    List<Material> data = (List<Material>) query.execute();
    if (data != null) {
      data = (List<Material>) pm.detachCopyAll(data);
      return new Results(data, null);
    }
  } catch (Exception e) {
    xLogger.severe(
        "Error while fetching material with no handling unit from domain {0} and query {1}",
        domainId, q, 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,代码行数:34,代码来源:MaterialDao.java

示例5: getUsers

import javax.jdo.Query; //导入方法依赖的package包/类
/**
 * Get users given the offset and size
 *
 * @param offset Offset
 * @param size   Number of users
 */
public List<IUserAccount> getUsers(int offset, int size) {
  PersistenceManager pm = null;
  Query query = null;
  List<IUserAccount> users = null;
  try {
    pm = PMF.get().getPersistenceManager();
    String
        queryStr =
        "SELECT * FROM USERACCOUNT ORDER BY USERID ASC limit " + offset + CharacterConstants.COMMA
            + size;
    query = pm.newQuery("javax.jdo.query.SQL", queryStr);
    query.setClass(UserAccount.class);
    users = (List<IUserAccount>) query.execute();
    users = (List<IUserAccount>) pm.detachCopyAll(users);
  } catch (Exception e) {
    xLogger.warn("Error encountered during user id migrations", e);
  } finally {
    if (query != null) {
      query.closeAll();
    }
    if (pm != null) {
      pm.close();
    }
  }
  return users;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:33,代码来源:UserDao.java

示例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;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:42,代码来源:UsersServiceImpl.java

示例7: getOrdersApprovalMapping

import javax.jdo.Query; //导入方法依赖的package包/类
public List<IOrderApprovalMapping> getOrdersApprovalMapping(Set<Long> orderIds,
                                                            int orderAppprovalType) {

  if (orderIds == null || orderIds.isEmpty()) {
    return null;
  }
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query query = null;
  List<IOrderApprovalMapping> results = null;
  try {

    StringBuilder queryBuilder = new StringBuilder("SELECT * FROM `ORDER_APPROVAL_MAPPING`");
    queryBuilder.append(" WHERE ORDER_ID IN (");
    for (Long orderId : orderIds) {
      queryBuilder.append(orderId).append(CharacterConstants.COMMA);
    }
    queryBuilder.setLength(queryBuilder.length() - 1);
    queryBuilder.append(" )");
    queryBuilder.append(" AND APPROVAL_TYPE=").append(orderAppprovalType);
    queryBuilder.append(" AND LATEST=1 ORDER BY ORDER_ID ASC");
    query = pm.newQuery("javax.jdo.query.SQL", queryBuilder.toString());
    query.setClass(OrderApprovalMapping.class);
    results = (List<IOrderApprovalMapping>) query.execute();
    results = (List<IOrderApprovalMapping>) 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;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:39,代码来源:OrderApprovalsServiceImpl.java

示例8: 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;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:35,代码来源:OrderDao.java

示例9: getDemandItems

import javax.jdo.Query; //导入方法依赖的package包/类
/**
 * Get all demand items by order Id
 *
 * @param orderId Order Id
 * @return -
 */
@Override
public List<IDemandItem> getDemandItems(Long orderId, PersistenceManager pm) {
  PersistenceManager localPM = pm;
  boolean useLocalPM = false;
  if (localPM == null) {
    localPM = PMF.get().getPersistenceManager();
    useLocalPM = true;
  }
  Query q = null;
  try {
    q = localPM.newQuery("javax.jdo.query.SQL", "SELECT * FROM DEMANDITEM WHERE OID=?");
    q.setClass(JDOUtils.getImplClass(IDemandItem.class));
    List<IDemandItem> items = (List<IDemandItem>) q.executeWithArray(orderId);
    if (items != null) {
      items = (List<IDemandItem>) localPM.detachCopyAll(items);
    }
    return items;
  } catch (Exception e) {
    xLogger.severe("Error while fetching demand items for order {0}", orderId, e);
  } finally {
    if (q != null) {
      q.closeAll();
    }
    if (useLocalPM) {
      localPM.close();
    }
  }
  return null;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:36,代码来源:DemandService.java

示例10: includeShipmentItems

import javax.jdo.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void includeShipmentItems(IShipment shipment, PersistenceManager pm) {
  if (shipment == null) {
    return;
  }
  Query src = null;
  try {
    src = pm.newQuery("javax.jdo.query.SQL", "SELECT * FROM SHIPMENTITEM WHERE sid = ?");
    src.setClass(JDOUtils.getImplClass(IShipmentItem.class));
    shipment
        .setShipmentItems((List<IShipmentItem>) src.executeWithArray(shipment.getShipmentId()));
    shipment
        .setShipmentItems((List<IShipmentItem>) pm.detachCopyAll(shipment.getShipmentItems()));
    src = pm.newQuery("javax.jdo.query.SQL", "SELECT * FROM SHIPMENTITEMBATCH WHERE siId = ?");
    src.setClass(JDOUtils.getImplClass(IShipmentItemBatch.class));
    for (IShipmentItem iShipmentItem : shipment.getShipmentItems()) {
      List<IShipmentItemBatch>
          sb =
          (List<IShipmentItemBatch>) src.executeWithArray(iShipmentItem.getShipmentItemId());
      iShipmentItem.setShipmentItemBatch((List<IShipmentItemBatch>) pm.detachCopyAll(sb));
    }
  } catch (Exception e) {
    xLogger
        .severe("Error while fetching shipment items for shipment: {0}", shipment.getShipmentId(),
            e);
  } finally {
    if (src != null) {
      src.closeAll();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:32,代码来源:ShipmentService.java

示例11: getInventory

import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public Results getInventory(InventoryFilters inventoryFilters, PageParams pageParams,
                            PersistenceManager pm)
    throws ServiceException {
  Query query = null;
  Query cntQuery = null;
  List<Invntry> inventoryList = null;
  int count = 0;
  try {
    QueryParams
        sqlQueryModel = buildInventoryQuery(inventoryFilters, false);
    String executeQuery = sqlQueryModel.query;
    if (pageParams != null) {
      executeQuery += " LIMIT " + pageParams.getOffset() + CharacterConstants.COMMA
          + pageParams.getSize();
    }
    query = pm.newQuery("javax.jdo.query.SQL", executeQuery);
    query.setClass(Invntry.class);
    inventoryList = (List<Invntry>) query.executeWithArray(
        sqlQueryModel.listParams.toArray());
    inventoryList = (List<Invntry>) pm.detachCopyAll(inventoryList);
    QueryParams cntSqlQueryModel = buildInventoryQuery(inventoryFilters, true);
    cntQuery = pm.newQuery("javax.jdo.query.SQL", cntSqlQueryModel.query);
    count =
        ((Long) ((List) cntQuery.executeWithArray(cntSqlQueryModel.listParams.toArray())).iterator().next())
            .intValue();

  } catch (Exception e){
    xLogger.severe("Error while reading inventory data", e);
  } finally {
    if (query != null) {
      query.closeAll();
    }
    if (cntQuery != null) {
      cntQuery.closeAll();
    }
  }
  return new Results(inventoryList, null, count,
      pageParams == null ? 0 : pageParams.getOffset());
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:41,代码来源:InvntryDao.java

示例12: closeOpenEvent

import javax.jdo.Query; //导入方法依赖的package包/类
private boolean closeOpenEvent(Long invId, PersistenceManager pm) {
  boolean useLocalPm = pm == null;
  if (useLocalPm) {
    pm = PMF.get().getPersistenceManager();
  }
  Query query = null;
  try {
    StringBuilder queryStr = new StringBuilder("SELECT * FROM INVNTRYEVNTLOG WHERE INVID = ");
    queryStr.append(invId);
    queryStr.append(" AND ED IS NULL");
    query =
        pm.newQuery("javax.jdo.query.SQL",
            queryStr.toString());
    query.setClass(JDOUtils.getImplClass(IInvntryEvntLog.class));
    query.setUnique(true);
    IInvntryEvntLog invntryEvntLog = (IInvntryEvntLog) query.execute();
    if (invntryEvntLog != null) {
      // Update the end date to now
      invntryEvntLog.setEndDate(new Date());
      pm.makePersistent(invntryEvntLog);
    }
  } catch (Exception e) {
    xLogger.warn(
        "Exception while closing open event for inventory item, invId: {0}", invId, e);
    return false;
  } finally {
    if (query != null) {
      query.closeAll();
    }
    if (useLocalPm) {
      pm.close();
    }
  }
  return true;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:36,代码来源:InventoryManagementServiceImpl.java

示例13: getKiosksForUser

import javax.jdo.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Results getKiosksForUser(IUserAccount user, String routeTag, PageParams pageParams,
                                 PersistenceManager pm) throws ServiceException {
  xLogger.fine("Entered getKiosks");
  if (user == null) {
    throw new IllegalArgumentException("Invalid user");
  }
  String
      query = "select UK.UserToKioskId as UserToKioskId, UK.* FROM USERTOKIOSK UK, KIOSK K where "
      + "UK.USERID = ? AND K.KIOSKID = UK.KIOSKID";
  List<String> parameters = new ArrayList<>(1);
  parameters.add(user.getUserId());
  if (StringUtils.isNotEmpty(routeTag)) {
    query += " AND UK.TG = ?";
    parameters.add(routeTag);
  }

  if(user.isRteEnabled() || routeTag != null){
    query += " ORDER BY UK.RI ASC";
  } else {
    query += " ORDER BY K.NAME ASC";
  }

  if (pageParams != null) {
    query  +=
        " LIMIT " + pageParams.getOffset() + CharacterConstants.COMMA + pageParams.getSize();
  }
  // Execute
  Query jdoQuery = pm.newQuery("javax.jdo.query.SQL", query);
  jdoQuery.setClass(UserToKiosk.class);
  List<UserToKiosk> results;
  List<IKiosk> kiosks = null;
  try {
    results = (List<UserToKiosk>) jdoQuery.executeWithArray(parameters.toArray());
    if (results != null && !results.isEmpty()) {
      kiosks = new ArrayList<>();
      for (IUserToKiosk uk : results) {
        try {
          IKiosk k = JDOUtils.getObjectById(IKiosk.class, uk.getKioskId(), pm);
          k = pm.detachCopy(k);
          k.setRouteIndex(uk.getRouteIndex());
          k.setRouteTag(uk.getTag());
          kiosks.add(k);
        } catch (JDOObjectNotFoundException e) {
          xLogger.warn("User's {0} kiosk {1} does not exist ", user.getUserId(), uk.getKioskId());
        }
      }
    }
  } finally {
    try {
      jdoQuery.closeAll();

    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }
  return new Results(kiosks, null);
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:60,代码来源:EntitiesServiceImpl.java

示例14: getLastMessage

import javax.jdo.Query; //导入方法依赖的package包/类
public IMessage getLastMessage(String convId, String objectType, String objectId){
  PersistenceManager pm = null;
  Query query = null;
  IMessage message = null;

  List<String> queryParamArray = new ArrayList<>();
  StringBuilder queryString = new StringBuilder("SELECT * FROM MESSAGE WHERE ");
  if (StringUtils.isNotBlank(convId)) {
    queryString.append("CONVERSATIONID = ").append(CharacterConstants.QUESTION);
    queryParamArray.add(convId);
  } else if (StringUtils.isNotBlank(objectType) && StringUtils.isNotBlank(objectId)) {
    queryString.append("CONVERSATIONID IN ( SELECT ID FROM CONVERSATION WHERE ")
            .append("OBJECTID = ").append(CharacterConstants.QUESTION)
            .append(" AND OBJECTTYPE = ").append(CharacterConstants.QUESTION)
            .append(" ) ");
    queryParamArray.add(objectId);
    queryParamArray.add(objectType);
  } else {
    throw new IllegalArgumentException(
            "One of conversation Id, and Object type/id combination is mandatory");
  }
  final String orderBy = " ORDER BY CREATEDATE DESC";
  queryString.append(orderBy);
  String limitStr = " LIMIT 1";
  queryString.append(limitStr);
  try {
    pm = PMF.get().getPersistenceManager();
    query = pm.newQuery("javax.jdo.query.SQL", queryString.toString());
    query.setClass(Message.class);

    List<Message> msgList = null;
    msgList = (List<Message>) query.executeWithArray(queryParamArray.toArray());
    msgList = (List<Message>) pm.detachCopyAll(msgList);
    if (msgList.size() > 0)
      message = msgList.get(0);
  } catch (Exception e){
    xLogger.severe("Exception while querying last message of conversation", 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;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:52,代码来源:MessageDao.java

示例15: getReportData

import javax.jdo.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public ReportData getReportData(Date from, Date until, String frequency,
                                Map<String, Object> filters, Locale locale, String timezone,
                                PageParams pageParams, DomainConfig dc, String sourceUserId)
    throws ReportingDataException {
  xLogger.fine("Entered StockEventDataGenerator.getReportData");
  // Execute query
  PersistenceManager pm = PMF.get().getPersistenceManager();
  int count = 0;
  // Query q = pm.newQuery( queryStr );
  boolean isAbnormalStockReport =
      ((filters.get(ReportsConstants.FILTER_ABNORMALSTOCKVIEW) != null)
          && (boolean) filters.get(ReportsConstants.FILTER_ABNORMALSTOCKVIEW));
  List results = null;
  String cursor = null;

  QueryParams queryParams =
      getReportQuery(
          from, until, frequency, filters, locale, timezone, pageParams, dc, sourceUserId);
  Query q = null;
  if (isAbnormalStockReport) {
    q = pm.newQuery("javax.jdo.query.SQL", queryParams.query);
    q.setClass(JDOUtils.getImplClass(IInvntry.class));
  } else {
    q = pm.newQuery(queryParams.query);
  }
  if (pageParams != null) {
    QueryUtil.setPageParams(q, pageParams);
  }
  xLogger.fine("Query: {0}, QueryParams: {1}", q, queryParams.params);
  try {
    // results = (List<InvntryEvntLog>) q.executeWithMap( params );
      results = (List<IInvntryEvntLog>) q.executeWithMap(queryParams.params);
    if(isAbnormalStockReport) {
      queryParams =
          getReportQuery(
              from, until, frequency, filters, locale, timezone, pageParams, dc, sourceUserId,
              true);
      q = pm.newQuery("javax.jdo.query.SQL", queryParams.query);
      count = ((Long) ((List) q.executeWithMap(queryParams.params)).iterator().next()).intValue();
    }
    if (results != null) {
      results.size();
      cursor = QueryUtil.getCursor(results);
      results = (List<IInvntryEvntLog>) pm.detachCopyAll(results);
    }
  } finally {
    try {
      q.closeAll();
    } catch (Exception ignored) {
      xLogger.warn("Exception while closing query", ignored);
    }
    pm.close();
  }

  xLogger.fine("Exiting StockEventDataGenerator.getReportData");
  return new StockEventData(from, until, filters, locale, timezone, results, cursor, count);
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:60,代码来源:StockEventDataGenerator.java


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