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


Java Query.setUnique方法代码示例

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


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

示例1: updateOrderApprovalStatus

import javax.jdo.Query; //导入方法依赖的package包/类
public void updateOrderApprovalStatus(Long orderId, String approvalId, String status) {
  if (orderId != null && StringUtils.isNotEmpty(approvalId)) {
    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 && approvalId == approvalIdParam ");
      query.declareParameters("Long orderIdParam, String approvalIdParam");
      params.put("orderIdParam", orderId);
      params.put(APPROVAL_ID_PARAM, approvalId);
      query.setUnique(true);
      IOrderApprovalMapping orderApprovalMapping = (IOrderApprovalMapping) query
          .executeWithMap(params);
      if (orderApprovalMapping != null) {
        orderApprovalMapping.setStatus(status);
        orderApprovalMapping.setUpdatedAt(new Date());
        pm.makePersistent(orderApprovalMapping);
      }
    } catch (Exception e) {
      xLogger.warn("Failed to get order approval mapping for order: {0} with approval: {1}",
          orderId, approvalId, e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          xLogger.warn(ignored.getMessage(), ignored);
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:38,代码来源:ApprovalsDao.java

示例2: getInvTotalCount

import javax.jdo.Query; //导入方法依赖的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

示例3: getUserDevice

import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public IUserDevice getUserDevice(String userid, String appname) throws ServiceException {

  IUserDevice userDevice = null;
  PersistenceManager pm = null;
  try {
    pm = PMF.get().getPersistenceManager();
    Query query = pm.newQuery(JDOUtils.getImplClass(IUserDevice.class));
    query.setFilter("userId == userIdParam && appname == appnameParam");
    query.declareParameters("String userIdParam, String appnameParam");
    //Query query = pm.newQuery("javax.jdo.query.SQL",q);
    query.setUnique(true);
    userDevice = (IUserDevice) query.execute(userid, appname);
    userDevice = pm.detachCopy(userDevice);
    return userDevice;
  } catch (Exception e) {
    xLogger.severe("{0} while getting user device {1}", e.getMessage(), userid, e);
    throw new ServiceException("Issue with getting user device for user :" + userid);
  } finally {
    if (pm != null) {
      pm.close();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:25,代码来源:UsersServiceImpl.java

示例4: isApprover

import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public Boolean isApprover(String userId) throws SQLException {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query query = null;
  IUserAccount userAccount;
  try {
    String
        sqlQuery =
        "SELECT 1 FROM APPROVERS WHERE UID = ? LIMIT 1";
    query = pm.newQuery(Constants.JAVAX_JDO_QUERY_SQL, sqlQuery);
    query.setUnique(true);
    if ((query.execute(userId)) != null) {
      return true;
    }
    userAccount = JDOUtils.getObjectById(IUserAccount.class, userId, pm);
    DomainConfig dc = DomainConfig.getInstance(userAccount.getDomainId());
    ApprovalsConfig.OrderConfig ac = dc.getApprovalsConfig().getOrderConfig();
    return ac != null && ac.isApprover(userId);
  } finally {
    if(query != null) {
      query.closeAll();
    }
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:26,代码来源:OrderApprovalsServiceImpl.java

示例5: findInvBatch

import javax.jdo.Query; //导入方法依赖的package包/类
public IInvntryBatch findInvBatch(Long kioskId, Long materialId, String batchId,
                                  PersistenceManager pm) {
  if (batchId == null) {
    throw new IllegalArgumentException("Batch Id cannot be null");
  }
  Query
      q =
      pm.newQuery("SELECT FROM " + JDOUtils.getImplClassName(IInvntryBatch.class)
          + " WHERE kId == kIdParam && " +
          "mId == mIdParam && bid == bIdParam PARAMETERS Long kIdParam, Long mIdParam, String bIdParam");
  Map<String, Object> params = new HashMap<>();
  params.put("kIdParam", kioskId);
  params.put("mIdParam", materialId);
  params.put("bIdParam", batchId.toUpperCase());
  try {
    q.setUnique(true);
    IInvntryBatch result = (IInvntryBatch) q.executeWithMap(params);
    return pm.detachCopy(result);
  } finally {
    if (q != null) {
      q.closeAll();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:25,代码来源:InvntryDao.java

示例6: getConversationById

import javax.jdo.Query; //导入方法依赖的package包/类
public IConversation getConversationById(String convId) throws ServiceException {
  IConversation conversation = null;
  PersistenceManager pm = null;
  try {
    pm = PMF.get().getPersistenceManager();
    Query query = pm.newQuery(JDOUtils.getImplClass(IConversation.class));
    query.setFilter("id == :convIdParam");
    Map<String, String> paramValues = new HashMap<>(1);
    paramValues.put("convIdParam", convId);
    query.setUnique(true);
    conversation = (IConversation) query.executeWithMap(paramValues);
    conversation = pm.detachCopy(conversation);
  } catch (Exception e) {
    xLogger.severe("{0} while creating getting conversation {1}", e.getMessage(), convId, e);
    throw new ServiceException(e);
  } finally {
    if (pm != null) {
      pm.close();
    }
  }
  return conversation;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:23,代码来源:ConversationServiceImpl.java

示例7: getSingle

import javax.jdo.Query; //导入方法依赖的package包/类
/**
 * Gets single result from Database
 * @param qp
 * @param pm
 * @param pageParams
 * @param <T>
 * @return
 */
public static <T> T getSingle(QueryParams qp, PersistenceManager pm,
                                  PageParams pageParams){
  T result = null;
  Query q = getQuery(qp, pm, pageParams);
  q.setUnique(true);
  try {
    result = (T) getResults(qp,q);
    if(result != null){
      result = pm.detachCopy(result);
    }
  } finally {
    q.closeAll();
  }
  return result;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:24,代码来源:JDOUtils.java

示例8: hasAccessToKiosk

import javax.jdo.Query; //导入方法依赖的package包/类
public Integer hasAccessToKiosk(String userId, Long kioskId) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Query query = null;
  try {
    String
        qry =
        "SELECT IF(R = 'c,v' OR R = 'v,c',GREATEST(C, V),IF(R = 'c', C, V)) Perm FROM(SELECT (SELECT GROUP_CONCAT(KL.LINKTYPE) R FROM KIOSKLINK KL WHERE KL.LINKEDKIOSKID = ?"
            +
            " AND KL.KIOSKID = K.KIOSKID) R,K.CPERM C,K.VPERM V FROM KIOSK K, (SELECT KIOSKID FROM USERTOKIOSK UK WHERE KIOSKID IN (SELECT DISTINCT KL.LINKEDKIOSKID FROM KIOSKLINK KL WHERE KIOSKID = ?)"
            +
            " AND USERID = ?) UK WHERE K.KIOSKID = UK.KIOSKID AND (K.CPERM > 0 OR K.VPERM > 0)) PERM limit 1";
    query = pm.newQuery("javax.jdo.query.SQL", qry);
    query.setUnique(true);
    Integer hasAccess = (Integer) query.executeWithArray(kioskId, kioskId, userId);
    if (hasAccess != null && hasAccess > 0) {
      return hasAccess;
    } else {
      return 0;
    }
  } finally {
    if (query != null) {
      try {
        query.closeAll();
      } catch (Exception ignored) {
        xLogger.warn("Exception while closing query", ignored);
      }
    }
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:31,代码来源:EntitiesServiceImpl.java

示例9: getOrderApprovalMapping

import javax.jdo.Query; //导入方法依赖的package包/类
public IOrderApprovalMapping getOrderApprovalMapping(Long orderId, String status) {
  IOrderApprovalMapping orderApprovalMapping = 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("status == statusParam && orderId == orderIdParam");
      query.declareParameters("String statusParam, Long orderIdParam");
      params.put(STATUS_PARAM, status);
      params.put(ORDER_ID_PARAM, orderId);
      query.setUnique(true);
      orderApprovalMapping = (IOrderApprovalMapping) query.executeWithMap(params);
      orderApprovalMapping = pm.detachCopy(orderApprovalMapping);
    } catch (Exception e) {
      xLogger.warn("Failed to get order approval mapping for order: {0} with status: {1}",
          orderApprovalMapping, status, e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          //ignored
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
  }
  return orderApprovalMapping;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:35,代码来源:ApprovalsDao.java

示例10: validateEntityBatchManagementUpdate

import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public boolean validateEntityBatchManagementUpdate(Long kioskId, PersistenceManager pm) throws ServiceException {
  if (kioskId == null) {
    throw new ServiceException("Invalid or null kioskId {0} while changing batch management on entity", kioskId);
  }
  boolean useLocalPm = false;
  if (pm == null) {
    pm = PMF.get().getPersistenceManager();
    useLocalPm = true;
  }

  Query query = null;
  List<String> parameters = new ArrayList<>(1);
  try {
    StringBuilder sqlQuery = new StringBuilder("SELECT 1 FROM INVNTRY I, MATERIAL M WHERE I.MID = M.MATERIALID AND M.BM = 1 AND I.STK > 0 AND I.KID = ").append(CharacterConstants.QUESTION);
    parameters.add(String.valueOf(kioskId));
    sqlQuery.append( " LIMIT 1");
    query = pm.newQuery("javax.jdo.query.SQL", sqlQuery.toString());
    query.setUnique(true);
    Long hasInv = (Long) query.executeWithArray(parameters.toArray());
    return (hasInv == null);
  } finally {
    if (query != null) {
      try {
        query.closeAll();
      } catch (Exception ignored) {
        xLogger.warn("Exception while closing query", ignored);
      }
    }
    if (useLocalPm) {
      pm.close();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:35,代码来源:InvntryDao.java

示例11: validateMaterialBatchManagementUpdate

import javax.jdo.Query; //导入方法依赖的package包/类
@Override
public boolean validateMaterialBatchManagementUpdate(Long materialId, PersistenceManager pm) throws ServiceException {
  if (materialId == null) {
    throw new ServiceException("Invalid or null materialId {0} while changing batch management on material", materialId);
  }
  boolean useLocalPm = false;
  if (pm == null) {
    pm = PMF.get().getPersistenceManager();
    useLocalPm = true;
  }

  Query query = null;
  List<String> parameters = new ArrayList<>(1);
  try {
    StringBuilder sqlQuery = new StringBuilder("SELECT 1 FROM INVNTRY I, MATERIAL M WHERE I.MID = M.MATERIALID AND M.MATERIALID = ").append(CharacterConstants.QUESTION);
    parameters.add(String.valueOf(materialId));
    sqlQuery.append(" AND I.STK > 0 LIMIT 1");
    query = pm.newQuery("javax.jdo.query.SQL", sqlQuery.toString());
    query.setUnique(true);
    Long hasInv = (Long) query.executeWithArray(parameters.toArray());
    return (hasInv == null);
  } finally {
    if (query != null) {
      try {
        query.closeAll();
      } catch (Exception ignored) {
        xLogger.warn("Exception while closing query", ignored);
      }
    }
    if (useLocalPm) {
      pm.close();
    }
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:35,代码来源: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: getInvMaterialCount

import javax.jdo.Query; //导入方法依赖的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

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

示例15: getApprovalType

import javax.jdo.Query; //导入方法依赖的package包/类
public Integer getApprovalType(Long orderId, String approvalId) {
  Integer type = null;
  if (orderId != null && StringUtils.isNotEmpty(approvalId)) {
    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 && approvalId == approvalIdParam");
      query.declareParameters("Long orderIdParam, String approvalIdParam");
      params.put("orderIdParam", orderId);
      params.put(APPROVAL_ID_PARAM, approvalId);
      query.setUnique(true);
      IOrderApprovalMapping
          orderApprovalMapping =
          (IOrderApprovalMapping) query.executeWithMap(params);
      orderApprovalMapping = pm.detachCopy(orderApprovalMapping);
      if (orderApprovalMapping != null) {
        type = orderApprovalMapping.getApprovalType();
      }
    } catch (Exception e) {
      xLogger
          .warn("Failed to get order approval mapping for order: {0} with approval: {1}",
              orderId,
              approvalId, e);
    } finally {
      if (query != null) {
        try {
          query.closeAll();
        } catch (Exception ignored) {
          xLogger.warn(ignored.getMessage(), ignored);
        }
      }
      if (pm != null) {
        pm.close();
      }
    }
  }
  return type;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:42,代码来源:ApprovalsDao.java


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