Class SelectById<T>

    • Method Detail

      • select

        public List<T> select​(ObjectContext context)
        Description copied from interface: Select
        Selects objects using provided context.

        Essentially the inversion of "ObjectContext.select(Select)".

        Specified by:
        select in interface Select<T>
      • selectOne

        public T selectOne​(ObjectContext context)
        Description copied from interface: Select
        Selects a single object using provided context. The query is expected to match zero or one object. It returns null if no objects were matched. If query matched more than one object, CayenneRuntimeException is thrown.

        Essentially the inversion of "ObjectContext.selectOne(Select)".

        Specified by:
        selectOne in interface Select<T>
      • selectFirst

        public T selectFirst​(ObjectContext context)
        Description copied from interface: Select
        Selects a single object using provided context. The query itself can match any number of objects, but will return only the first one. It returns null if no objects were matched.

        If it matched more than one object, the first object from the list is returned. This makes 'selectFirst' different from Select.selectOne(ObjectContext), which would throw in this situation. 'selectFirst' is useful e.g. when the query is ordered and we only want to see the first object (e.g. "most recent news article"), etc.

        Selecting the first object via "Select.selectFirst(ObjectContext)" is more comprehensible than selecting via "ObjectContext.selectFirst(Select)", because implementations of "Select" set fetch size limit to one.

        Specified by:
        selectFirst in interface Select<T>
      • iterate

        public void iterate​(ObjectContext context,
                            ResultIteratorCallback<T> callback)
        Description copied from interface: Select
        Creates a ResultIterator based on the provided context and passes it to a callback for processing. The caller does not need to worry about closing the iterator. This method takes care of it.

        Essentially the inversion of "ObjectContext.iterate(Select, ResultIteratorCallback)".

        Specified by:
        iterate in interface Select<T>
      • iterator

        public ResultIterator<T> iterator​(ObjectContext context)
        Description copied from interface: Select
        Creates a ResultIterator based on the provided context. It is usually backed by an open result set and is useful for processing of large data sets, preserving a constant memory footprint. The caller must wrap iteration in try/finally (or try-with-resources for Java 1.7 and higher) and close the ResultIterator explicitly. Or use Select.iterate(ObjectContext, ResultIteratorCallback) as an alternative.

        Essentially the inversion of "ObjectContext.iterator(Select)".

        Specified by:
        iterator in interface Select<T>
      • batchIterator

        public ResultBatchIterator<T> batchIterator​(ObjectContext context,
                                                    int size)
        Description copied from interface: Select
        Creates a ResultBatchIterator based on the provided context and batch size. It is usually backed by an open result set and is useful for processing of large data sets, preserving a constant memory footprint. The caller must wrap iteration in try/finally (or try-with-resources for Java 1.7 and higher) and close the ResultBatchIterator explicitly.
        Specified by:
        batchIterator in interface Select<T>
      • localCache

        public SelectById<T> localCache​(String cacheGroup)
        Instructs Cayenne to look for query results in the "local" cache when running the query. This is a short-hand notation for:
         query.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE, cacheGroup);
         
      • localCache

        public SelectById<T> localCache()
        Instructs Cayenne to look for query results in the "local" cache when running the query. This is a short-hand notation for:
         query.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
         
      • sharedCache

        public SelectById<T> sharedCache​(String cacheGroup)
        Instructs Cayenne to look for query results in the "shared" cache when running the query. This is a short-hand notation for:
         query.cacheStrategy(QueryCacheStrategy.SHARED_CACHE, cacheGroup);
         
      • sharedCache

        public SelectById<T> sharedCache()
        Instructs Cayenne to look for query results in the "shared" cache when running the query. This is a short-hand notation for:
         query.cacheStrategy(QueryCacheStrategy.SHARED_CACHE);
         
      • getCacheGroup

        public String getCacheGroup()
      • isFetchingDataRows

        public boolean isFetchingDataRows()
      • prefetch

        public SelectById<T> prefetch​(PrefetchTreeNode prefetch)
        Merges prefetch into the query prefetch tree.
        Returns:
        this object
      • prefetch

        public SelectById<T> prefetch​(String path,
                                      int semantics)
        Merges a prefetch path with specified semantics into the query prefetch tree.
        Returns:
        this object