com.tcdng.unify.core.database.Query.add()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中com.tcdng.unify.core.database.Query.add方法的一些代码示例,展示了Query.add的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.add方法的具体详情如下:
包路径:com.tcdng.unify.core.database.Query
类名称:Query
方法名:add

Query.add介绍

暂无

代码示例

代码示例来源:origin: com.tcdng.jacklyn/jacklyn-system

@Override
public List<SystemControlState> findSystemControlStates(SystemParameterQuery query) throws UnifyException {
  List<SystemControlState> systemControlStateList = new ArrayList<SystemControlState>();
  Criteria criteria = query.getCriteria();
  Query<SystemParameter> innerQuery =
      query.copyNoCriteria().add(criteria).equals("control", Boolean.TRUE).order("name");
  int index = 0;
  List<SystemParameter> list = db().findAll(innerQuery);
  for (SystemParameter sysParameter : list) {
    systemControlStateList.add(new SystemControlState(index++, sysParameter.getName(),
        sysParameter.getDescription(), convert(boolean.class, sysParameter.getValue(), null)));
  }
  return systemControlStateList;
}

代码示例来源:origin: com.tcdng.unify/unify-core

@Override
public <T extends Entity> List<T> findAll(Query<T> query) throws UnifyException {
  try {
    SqlEntityInfo sqlEntityInfo = sqlDataSourceDialect.getSqlEntityInfo(query.getEntityClass());
    if (sqlEntityInfo.testTrueFieldNamesOnly(query.getFields())) {
      return getSqlStatementExecutor().executeMultipleRecordResultQuery(connection,
          sqlDataSourceDialect.prepareFindStatement(query));
    }
    SqlFieldInfo idFieldInfo = sqlEntityInfo.getIdFieldInfo();
    List<?> idList = valueList(idFieldInfo.getFieldType(), idFieldInfo.getName(), query);
    if (!idList.isEmpty()) {
      Query<T> findQuery = query.copyNoCriteria();
      findQuery.add(new Amongst(idFieldInfo.getName(), idList));
      return getSqlStatementExecutor().executeMultipleRecordResultQuery(connection,
          sqlDataSourceDialect.prepareFindStatement(findQuery));
    }
  } catch (UnifyException e) {
    throw e;
  } catch (Exception e) {
    throw new UnifyException(e, UnifyCoreErrorConstants.COMPONENT_OPERATION_ERROR, getClass().getSimpleName());
  }
  return new ArrayList<T>();
}

代码示例来源:origin: com.tcdng.unify/unify-core

@Override
public <T, U extends Entity> Map<T, List<U>> findAllListMap(Class<T> keyClass, String keyName, Query<U> query)
    throws UnifyException {
  try {
    SqlEntityInfo sqlEntityInfo = sqlDataSourceDialect.getSqlEntityInfo(query.getEntityClass());
    if (sqlEntityInfo.testTrueFieldNamesOnly(query.getFields())) {
      return getSqlStatementExecutor().executeMultipleRecordListResultQuery(connection, keyClass, keyName,
          sqlDataSourceDialect.prepareFindStatement(query));
    }
    SqlFieldInfo idFieldInfo = sqlEntityInfo.getIdFieldInfo();
    List<?> idList = valueList(idFieldInfo.getFieldType(), idFieldInfo.getName(), query);
    if (!idList.isEmpty()) {
      Query<U> findQuery = query.copyNoCriteria();
      findQuery.add(new Amongst(idFieldInfo.getName(), idList));
      return getSqlStatementExecutor().executeMultipleRecordListResultQuery(connection, keyClass, keyName,
          sqlDataSourceDialect.prepareFindStatement(findQuery));
    }
  } catch (UnifyException e) {
    throw e;
  } catch (Exception e) {
    throw new UnifyException(e, UnifyCoreErrorConstants.COMPONENT_OPERATION_ERROR, getClass().getSimpleName());
  }
  return new HashMap<T, List<U>>();
}

代码示例来源:origin: com.tcdng.unify/unify-core

@Override
public <T, U extends Entity> Map<T, U> findAllMap(Class<T> keyClass, String keyName, Query<U> query)
    throws UnifyException {
  try {
    SqlEntityInfo sqlEntityInfo = sqlDataSourceDialect.getSqlEntityInfo(query.getEntityClass());
    if (sqlEntityInfo.testTrueFieldNamesOnly(query.getFields())) {
      return getSqlStatementExecutor().executeMultipleRecordResultQuery(connection, keyClass, keyName,
          sqlDataSourceDialect.prepareFindStatement(query));
    }
    SqlFieldInfo idFieldInfo = sqlEntityInfo.getIdFieldInfo();
    List<?> idList = valueList(idFieldInfo.getFieldType(), idFieldInfo.getName(), query);
    if (!idList.isEmpty()) {
      Query<U> findQuery = query.copyNoCriteria();
      findQuery.add(new Amongst(idFieldInfo.getName(), idList));
      return getSqlStatementExecutor().executeMultipleRecordResultQuery(connection, keyClass, keyName,
          sqlDataSourceDialect.prepareFindStatement(findQuery));
    }
  } catch (UnifyException e) {
    throw e;
  } catch (Exception e) {
    throw new UnifyException(e, UnifyCoreErrorConstants.COMPONENT_OPERATION_ERROR, getClass().getSimpleName());
  }
  return new HashMap<T, U>();
}

代码示例来源:origin: com.tcdng.unify/unify-core

@Override
public List<Aggregate<?>> aggregate(AggregateType aggregateType, Query<? extends Entity> query)
    throws UnifyException {
  try {
    SqlEntityInfo sqlEntityInfo = sqlDataSourceDialect.getSqlEntityInfo(query.getEntityClass());
    if (sqlEntityInfo.testTrueFieldNamesOnly(query.getFields())) {
      return getSqlStatementExecutor().executeMultipleAggregateResultQuery(connection,
          sqlDataSourceDialect.getSqlTypePolicy(int.class),
          sqlDataSourceDialect.prepareAggregateStatement(aggregateType, query));
    }
    SqlFieldInfo idFieldInfo = sqlEntityInfo.getIdFieldInfo();
    List<?> idList = valueList(idFieldInfo.getFieldType(), idFieldInfo.getName(), query);
    if (!idList.isEmpty()) {
      Query<? extends Entity> aggregateQuery = query.copyNoCriteria();
      aggregateQuery.add(new Amongst(idFieldInfo.getName(), idList));
      return getSqlStatementExecutor().executeMultipleAggregateResultQuery(connection,
          sqlDataSourceDialect.getSqlTypePolicy(int.class),
          sqlDataSourceDialect.prepareAggregateStatement(aggregateType, aggregateQuery));
    }
  } catch (UnifyException e) {
    throw e;
  } catch (Exception e) {
    throw new UnifyException(e, UnifyCoreErrorConstants.COMPONENT_OPERATION_ERROR, getClass().getSimpleName());
  }
  return Collections.emptyList();
}

代码示例来源:origin: com.tcdng.unify/unify-core

@Override
public int updateAll(Query<? extends Entity> query, Update update) throws UnifyException {
  try {
    SqlEntityInfo sqlEntityInfo = sqlDataSourceDialect.getSqlEntityInfo(query.getEntityClass());
    if (sqlDataSourceDialect.isQueryOffsetOrLimit(query)
        || (sqlEntityInfo.testTrueFieldNamesOnly(query.getFields()))) {
      return getSqlStatementExecutor().executeUpdate(connection,
          sqlDataSourceDialect.prepareUpdateStatement(query, update));
    }
    SqlFieldInfo idFieldInfo = sqlEntityInfo.getIdFieldInfo();
    List<?> idList = valueList(idFieldInfo.getFieldType(), idFieldInfo.getName(), query);
    if (!idList.isEmpty()) {
      Query<? extends Entity> updateQuery = query.copyNoAll();
      updateQuery.add(new Amongst(idFieldInfo.getName(), idList));
      return getSqlStatementExecutor().executeUpdate(connection,
          sqlDataSourceDialect.prepareUpdateStatement(updateQuery, update));
    }
  } catch (UnifyException e) {
    throw e;
  } catch (Exception e) {
    throw new UnifyException(e, UnifyCoreErrorConstants.COMPONENT_OPERATION_ERROR, getClass().getSimpleName());
  }
  return 0;
}

代码示例来源:origin: com.tcdng.unify/unify-core

@Override
public <T extends Entity> T find(Query<T> query) throws UnifyException {
  T record = null;
  try {
    SqlEntityInfo sqlEntityInfo = sqlDataSourceDialect.getSqlEntityInfo(SqlUtils.getEntityClass(query));
    if (sqlEntityInfo.testTrueFieldNamesOnly(query.getFields())) {
      record = getSqlStatementExecutor().executeSingleRecordResultQuery(connection,
          sqlDataSourceDialect.prepareFindStatement(query), false);
    } else {
      SqlFieldInfo idFieldInfo = sqlEntityInfo.getIdFieldInfo();
      List<?> idList = valueList(idFieldInfo.getFieldType(), idFieldInfo.getName(), query);
      if (!idList.isEmpty()) {
        Query<T> findQuery = query.copyNoCriteria();
        findQuery.add(new Amongst(idFieldInfo.getName(), idList));
        record = getSqlStatementExecutor().executeSingleRecordResultQuery(connection,
            sqlDataSourceDialect.prepareFindStatement(findQuery), false);
      }
    }
    fetchChildRecords(record, query.getSelect(), false);
  } catch (UnifyException e) {
    throw e;
  } catch (Exception e) {
    throw new UnifyException(e, UnifyCoreErrorConstants.COMPONENT_OPERATION_ERROR, getClass().getSimpleName());
  }
  return record;
}

代码示例来源:origin: com.tcdng.unify/unify-core

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public int count(Query<? extends Entity> query) throws UnifyException {
  try {
    SqlEntityInfo sqlEntityInfo = sqlDataSourceDialect.getSqlEntityInfo(query.getEntityClass());
    if (sqlEntityInfo.testTrueFieldNamesOnly(query.getFields())) {
      return getSqlStatementExecutor().executeSingleObjectResultQuery(connection, int.class,
          sqlDataSourceDialect.getSqlTypePolicy(int.class),
          sqlDataSourceDialect.prepareCountStatement(query), true);
    }
    SqlFieldInfo idFieldInfo = sqlEntityInfo.getIdFieldInfo();
    List<?> idList = valueList(idFieldInfo.getFieldType(), idFieldInfo.getName(), query);
    if (!idList.isEmpty()) {
      Query<? extends Entity> countQuery = new Query(query.getEntityClass(), query.isApplyAppQueryLimit());
      countQuery.add(new Amongst(idFieldInfo.getName(), idList));
      return getSqlStatementExecutor().executeSingleObjectResultQuery(connection, int.class,
          sqlDataSourceDialect.getSqlTypePolicy(int.class),
          sqlDataSourceDialect.prepareCountStatement(countQuery), true);
    }
  } catch (UnifyException e) {
    throw e;
  } catch (Exception e) {
    throw new UnifyException(e, UnifyCoreErrorConstants.COMPONENT_OPERATION_ERROR, getClass().getSimpleName());
  }
  return 0;
}

代码示例来源:origin: com.tcdng.unify/unify-core

deleteQuery.add(new Amongst(idFieldInfo.getName(), idList));
return getSqlStatementExecutor().executeUpdate(connection,
    sqlDataSourceDialect.prepareDeleteStatement(deleteQuery));

相关文章