Examples of SelectQuery


Examples of org.apache.cayenne.query.SelectQuery

        this.rootEntity = metadata.getObjEntity();

        // create an internal query, it is a partial replica of
        // the original query and will serve as a value holder for
        // various parameters
        this.internalQuery = new SelectQuery(rootEntity);
        this.internalQuery.setFetchingDataRows(metadata.isFetchingDataRows());
        this.internalQuery.setResolvingInherited(metadata.isResolvingInherited());
        this.internalQuery.setPrefetchTree(metadata.getPrefetchTree());

        this.helper = createHelper(metadata);

        boolean resolvesFirstPage = true;

        if (!metadata.isFetchingDataRows() && (query instanceof SelectQuery)) {
            SelectQuery select = (SelectQuery) query;

            // optimize SelectQuery:
            // * just select ID columns - this gives a 5-10x speedup
            // * strip prefetches as they blow the iterated result, and are actually not
            // needed

            SelectQuery clone = select.queryWithParameters(Collections.EMPTY_MAP, true);
            clone.clearPrefetches();

            // I guess this check is redundant, as custom attributes warrant data rows
            if (!select.isFetchingCustomAttributes()) {
                for (DbAttribute attribute : rootEntity.getDbEntity().getPrimaryKeys()) {
                    clone.addCustomDbAttribute(attribute.getName());
                }
            }

            query = clone;
            resolvesFirstPage = false;
View Full Code Here

Examples of org.apache.cayenne.query.SelectQuery

            boolean fetchesDataRows = internalQuery.isFetchingDataRows();
            List objects = new ArrayList(qualsSize);
            int fetchEnd = Math.min(qualsSize, maxFetchSize);
            int fetchBegin = 0;
            while (fetchBegin < qualsSize) {
                SelectQuery query = new SelectQuery(rootEntity, ExpressionFactory
                        .joinExp(Expression.OR, quals.subList(fetchBegin, fetchEnd)));

                query.setFetchingDataRows(fetchesDataRows);

                if (!query.isFetchingDataRows()) {
                    query.setPrefetchTree(internalQuery.getPrefetchTree());
                }

                objects.addAll(dataContext.performQuery(query));
                fetchBegin = fetchEnd;
                fetchEnd += Math.min(maxFetchSize, qualsSize - fetchEnd);
View Full Code Here

Examples of org.apache.cayenne.query.SelectQuery

  @SuppressWarnings("unchecked")
  public DatabaseEditor(Class<T> clazz) throws Exception {
    context = DatabaseContext.getContext();
    if(context == null)
      throw new UnloggedException("No database is initialized");
    List<T> dataRows = context.performQuery(new SelectQuery(clazz));
    Collections.sort(dataRows);

    editorType = clazz.getSimpleName();
    jf.setTitle(editorType + " Editor");
    Box box = new Box(BoxLayout.X_AXIS);
View Full Code Here

Examples of org.apache.cayenne.query.SelectQuery

      bNull = null;
      jp.add(new JLabel(), gbc);
    }

    final HashMap<String, T> theseOptions = new HashMap<String, T>();
    List<T> relTargets = context.performQuery(new SelectQuery(fieldType));
    Collections.sort(relTargets);
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    for(T v : relTargets) {
      String s = getDisplayString(v);
      model.addElement(s);
View Full Code Here

Examples of org.apache.cayenne.query.SelectQuery

   * @return The Account or NULL
   */
  public static Account get(String name) {
    try {
      Expression expression = ExpressionFactory.likeIgnoreCaseExp(Account.NAME_PROPERTY, name);
      SelectQuery query = new SelectQuery(Account.class, expression);
      return (Account)DataObjectUtils.objectForQuery(DatabaseContext.getContext(), query);
    } catch(Exception e) {
      Out.exception(e);
      return null;
    }
View Full Code Here

Examples of org.apache.cayenne.query.SelectQuery

   * @return A List&lt;Account> of users with at minimum access
   */
  @SuppressWarnings("unchecked")
  public static List<Account> getRanked(int rank) {
    Expression expression = ExpressionFactory.greaterOrEqualExp(Account.RANK_PROPERTY, rank);
    SelectQuery query = new SelectQuery(Account.class, expression);
    return DatabaseContext.getContext().performQuery(query);
  }
View Full Code Here

Examples of org.apache.cayenne.query.SelectQuery

   * @return A List&lt;Account> of all users with trivia_correct>0, descending
   */
  @SuppressWarnings("unchecked")
  public static List<Account> getTriviaLeaders() {
    Expression expression = ExpressionFactory.greaterExp(Account.TRIVIA_CORRECT_PROPERTY, Integer.valueOf(0));
    SelectQuery query = new SelectQuery(Account.class, expression);
    query.addOrdering(Account.TRIVIA_CORRECT_PROPERTY, false);
    return DatabaseContext.getContext().performQuery(query);
  }
View Full Code Here

Examples of org.apache.cayenne.query.SelectQuery

      if(ca != null)
        return ca.getToCommand();

      // No aliases found; check for the real command
      Expression expression = ExpressionFactory.matchExp(Command.NAME_PROPERTY, command);
      SelectQuery query = new SelectQuery(Command.class, expression);
      return (Command)DataObjectUtils.objectForQuery(DatabaseContext.getContext(), query);
    } catch(Exception e) {
      return null;
    }
  }
View Full Code Here

Examples of org.apache.cayenne.query.SelectQuery

   * @param access Minimum access
   * @return List of commands
   */
  @SuppressWarnings("unchecked")
  public static List<Command> getCommands(int access) {
    SelectQuery query = new SelectQuery(Command.class);
    List<Command> commands = DatabaseContext.getContext().performQuery(query);
    List<Command> ret = new ArrayList<Command>(commands.size());
    for(Command c : commands)
      if(c.getAccess() <= access)
        ret.add(c);
View Full Code Here

Examples of org.apache.cayenne.query.SelectQuery

   * @return List of commands
   */
  @SuppressWarnings("unchecked")
  public static List<Command> getCommands(String category, int access) {
    Expression expression = ExpressionFactory.likeIgnoreCaseExp(Command.CMDGROUP_PROPERTY, category);
    SelectQuery query = new SelectQuery(Command.class, expression);
    List<Command> commands = DatabaseContext.getContext().performQuery(query);
    List<Command> ret = new ArrayList<Command>(commands.size());
    for(Command c : commands)
      if(c.getAccess() <= access)
        ret.add(c);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.