com.psddev.dari.db.Query.using()方法的使用及代码示例

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

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

Query.using介绍

暂无

代码示例

代码示例来源:origin: perfectsense/dari

  1. /**
  2. * Creates a new instance that runs in the given {@code executor},
  3. * and produces items that match the given {@code query} from the
  4. * given {@code database} into the given {@code output} queue.
  5. *
  6. * @param executor If {@code null}, uses the default executor.
  7. * @param output If {@code null}, creates a new queue.
  8. * @param database Can't be {@code null}.
  9. * @param query Can't be {@code null}.
  10. * @throws IllegalArgumentException If the given {@code database}
  11. * or {@code query} is {@code null}.
  12. */
  13. public AsyncDatabaseReader(
  14. String executor,
  15. AsyncQueue<E> output,
  16. Database database,
  17. Query<E> query) {
  18. super(executor, output);
  19. if (database == null) {
  20. throw new IllegalArgumentException("Database can't be null!");
  21. }
  22. if (query == null) {
  23. throw new IllegalArgumentException("Query can't be null!");
  24. }
  25. this.iterator = query.using(database).iterable(0).iterator();
  26. }

代码示例来源:origin: perfectsense/dari

  1. .from(Object.class)
  2. .where("_id = ?", keyId)
  3. .using(database)
  4. .noCache()
  5. .master()

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public void doTask() {
  3. Database database = getDatabase();
  4. Date newGlobalsUpdate = Query
  5. .from(Object.class)
  6. .where("_id = ?", GLOBALS_ID)
  7. .using(database)
  8. .lastUpdate();
  9. if (newGlobalsUpdate != null
  10. && (lastGlobalsUpdate == null
  11. || newGlobalsUpdate.after(lastGlobalsUpdate))) {
  12. refreshGlobals();
  13. }
  14. Date newTypesUpdate = Query
  15. .from(ObjectType.class)
  16. .using(database)
  17. .lastUpdate();
  18. if (newTypesUpdate != null
  19. && (lastTypesUpdate == null
  20. || newTypesUpdate.after(lastTypesUpdate))) {
  21. refreshTypes();
  22. }
  23. }
  24. };

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. @SuppressWarnings("unchecked")
  3. public void ping() {
  4. Database defaultDatabase = Database.Static.getDefault();
  5. if (defaultDatabase instanceof Iterable) {
  6. for (Database delegate : (Iterable<Database>) defaultDatabase) {
  7. Query.from(Object.class).using(delegate).first();
  8. }
  9. } else {
  10. Query.from(Object.class).first();
  11. }
  12. }
  13. }

代码示例来源:origin: perfectsense/dari

  1. private static Map<String, BootstrapPackage> getPackagesMap(Database database) {
  2. Map<String, BootstrapPackage> packagesByName = new TreeMap<String, BootstrapPackage>();
  3. // First create the _init package for the whole database
  4. BootstrapPackage initPkg = new BootstrapPackage();
  5. initPkg.setName(INIT_NAME);
  6. initPkg.setIsInit(true);
  7. packagesByName.put(INIT_NAME, initPkg);
  8. for (ObjectType type : database.getEnvironment().getTypes()) {
  9. TypeData bmod = type.as(TypeData.class);
  10. for (String name : bmod.getPackageNames()) {
  11. BootstrapPackage pkg = packagesByName.get(name);
  12. if (pkg == null) {
  13. pkg = new BootstrapPackage();
  14. pkg.setName(name);
  15. packagesByName.put(name, pkg);
  16. }
  17. pkg.getTypes().add(type);
  18. }
  19. }
  20. for (BootstrapPackage pkg : Query.from(BootstrapPackage.class).using(database).selectAll()) {
  21. packagesByName.put(pkg.getName(), pkg);
  22. }
  23. for (Map.Entry<String, BootstrapPackage> entry : packagesByName.entrySet()) {
  24. checkConsistency(database, entry.getValue(), new HashSet<BootstrapPackage>(packagesByName.values()), null);
  25. }
  26. return packagesByName;
  27. }

代码示例来源:origin: perfectsense/dari

  1. Set<UUID> objectIds = ID_CACHE.getIfPresent(url);
  2. if (objectIds != null) {
  3. Query.from(Object.class).using(caching).where("id = ?", objectIds).selectAll();

代码示例来源:origin: perfectsense/dari

  1. .from(Object.class)
  2. .where("_id = ?", unresolvedIds)
  3. .using(database)
  4. .option(State.REFERENCE_RESOLVING_QUERY_OPTION, parent)
  5. .option(State.REFERENCE_FIELD_QUERY_OPTION, field)

代码示例来源:origin: perfectsense/dari

  1. private Query<?> createQuery(Database database, WebPageContext context) {
  2. String queryString = context.param(String.class, WebDatabase.QUERY_PARAMETER);
  3. Object queryObject = ObjectUtils.fromJson(queryString);
  4. if (!(queryObject instanceof Map)) {
  5. throw new DatabaseException(database, String.format(
  6. "Invalid query string! (%s)", queryString));
  7. }
  8. @SuppressWarnings("unchecked")
  9. Map<String, Object> queryMap = (Map<String, Object>) queryObject;
  10. convertTypeNameToId(database.getEnvironment(), queryMap);
  11. Query<?> query = Query.fromAll();
  12. query.getState().putAll(queryMap);
  13. query.using(database);
  14. return query;
  15. }

代码示例来源:origin: perfectsense/dari

  1. LastResummarization last = Query.from(LastResummarization.class).using(database).where("key = ?", key).first();
  2. if (last == null) {
  3. last = new LastResummarization();

代码示例来源:origin: perfectsense/dari

  1. .from(Object.class)
  2. .where("_id = ?", id)
  3. .using(this)
  4. .option(CONNECTION_QUERY_OPTION, connection)
  5. .option(RETURN_ORIGINAL_DATA_QUERY_OPTION, Boolean.TRUE)

代码示例来源:origin: perfectsense/dari

  1. .from(Object.class)
  2. .where("id != ?", state.getId())
  3. .using(state.getDatabase())
  4. .referenceOnly()
  5. .noCache()

代码示例来源:origin: perfectsense/dari

  1. .using(database)
  2. .selectAll();
  3. int typesSize = types.size();

代码示例来源:origin: perfectsense/dari

  1. Query<?> query = Query.fromAll().using(db).noCache().resolveToReferenceOnly().option(SqlDatabase.USE_JDBC_FETCH_SIZE_QUERY_OPTION, false);
  2. if (!isGlobal) {
  3. Set<ObjectType> concreteTypes = new HashSet<>();

代码示例来源:origin: perfectsense/dari

  1. .from(Object.class)
  2. .where("_id = ?", keyId)
  3. .using(database)
  4. .noCache()
  5. .master()

代码示例来源:origin: perfectsense/dari

  1. query.using(caching);
  2. query.resolveInvisible();

代码示例来源:origin: perfectsense/dari

  1. /** Immediately refreshes all globals using the backing database. */
  2. public synchronized void refreshGlobals() {
  3. bootstrapOnce.ensure();
  4. Database database = getDatabase();
  5. LOGGER.info("Loading globals from [{}]", database.getName());
  6. Query<Object> globalsQuery = Query
  7. .from(Object.class)
  8. .where("_id = ?", GLOBALS_ID)
  9. .using(database)
  10. .noCache();
  11. State newGlobals = State.getInstance(globalsQuery.first());
  12. if (newGlobals == null) {
  13. newGlobals = State.getInstance(globalsQuery.master().first());
  14. }
  15. if (newGlobals == null) {
  16. newGlobals = new State();
  17. newGlobals.setDatabase(database);
  18. newGlobals.setId(GLOBALS_ID);
  19. newGlobals.save();
  20. }
  21. globals = newGlobals;
  22. lastGlobalsUpdate = new Date();
  23. fieldsCache.reset();
  24. metricFieldsCache.reset();
  25. indexesCache.reset();
  26. }

代码示例来源:origin: perfectsense/dari

  1. State state = State.getInstance(Query.fromAll()
  2. .where("_id = ?", page.param(UUID.class, "id"))
  3. .using(database)
  4. .resolveInvisible()
  5. .first());

代码示例来源:origin: perfectsense/dari

  1. /**
  2. * Validates the given {@code state} against the constraints defined
  3. * in this index.
  4. *
  5. * @return {@code true} if there aren't any errors.
  6. */
  7. public boolean validate(State state) {
  8. if (isUnique()) {
  9. Object value = getValue(state);
  10. if (!ObjectUtils.isBlank(value)) {
  11. Object duplicate = Query
  12. .from(Object.class)
  13. .where("id != ?", state.getId())
  14. .and(getUniqueName() + " = ?", value)
  15. .using(state.getDatabase())
  16. .referenceOnly()
  17. .first();
  18. if (duplicate != null) {
  19. state.addError(state.getField(getField()), "Must be unique!");
  20. return false;
  21. }
  22. }
  23. }
  24. return true;
  25. }

代码示例来源:origin: perfectsense/dari

  1. Query<T> query = Query.from(applicationClass).where("_type = ?", type.getId()).using(database);
  2. T app = query.first();

代码示例来源:origin: perfectsense/dari

  1. .from(Object.class)
  2. .where("_id = ?", id)
  3. .using(this)
  4. .option(CONNECTION_QUERY_OPTION, connection)
  5. .option(RETURN_ORIGINAL_DATA_QUERY_OPTION, Boolean.TRUE)

相关文章