com.trg.search.jpa
Class JPASearchProcessor

java.lang.Object
  extended by com.trg.search.BaseSearchProcessor
      extended by com.trg.search.jpa.JPASearchProcessor

public class JPASearchProcessor
extends BaseSearchProcessor

Implementation of BaseSearchProcessor that works with JPA.

This class is designed to be used as a singleton. The constructor requires a MetadataUtil instance. Each MetadataUtil instance is typically associated with a single persistence unit (i.e. EntityManagerFactory). A JPASearchProcessor can only be used with EntityManagers that are associated with the same persistence unit as the MetadataUtil. If an application has multiple persistence units, it will need to have multiple corresponding Search Processors.

Author:
dwolverton

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trg.search.BaseSearchProcessor
BaseSearchProcessor.AliasNode, BaseSearchProcessor.SearchContext
 
Field Summary
 
Fields inherited from class com.trg.search.BaseSearchProcessor
INJECTION_CHECK, metadataUtil, qlType, QLTYPE_EQL, QLTYPE_HQL, ROOT_PATH, rootAlias
 
Constructor Summary
JPASearchProcessor(MetadataUtil mdu)
           
 
Method Summary
 int count(javax.persistence.EntityManager entityManager, java.lang.Class<?> searchClass, ISearch search)
          Returns the total number of results that would be returned using the given ISearch if there were no paging or maxResult limits.
 int count(javax.persistence.EntityManager entityManager, ISearch search)
          Returns the total number of results that would be returned using the given ISearch if there were no paging or maxResult limits.
 java.util.List search(javax.persistence.EntityManager entityManager, java.lang.Class<?> searchClass, ISearch search)
          Search for objects based on the search parameters in the specified ISearch object.
 java.util.List search(javax.persistence.EntityManager entityManager, ISearch search)
          Search for objects based on the search parameters in the specified ISearch object.
 SearchResult searchAndCount(javax.persistence.EntityManager entityManager, java.lang.Class<?> searchClass, ISearch search)
          Returns a SearchResult object that includes the list of results like search() and the total length like searchLength.
 SearchResult searchAndCount(javax.persistence.EntityManager entityManager, ISearch search)
          Returns a SearchResult object that includes the list of results like search() and the total length like searchLength.
 java.lang.Object searchUnique(javax.persistence.EntityManager entityManager, java.lang.Class<?> entityClass, ISearch search)
          Search for a single result using the given parameters.
 java.lang.Object searchUnique(javax.persistence.EntityManager entityManager, ISearch search)
          Search for a single result using the given parameters.
 
Methods inherited from class com.trg.search.BaseSearchProcessor
addExplicitNullChecks, applyFetches, checkAndCleanFetches, checkAndCleanFields, checkAndCleanFilters, checkAndCleanSorts, filterToQL, generateFromClause, generateJoins, generateOrderByClause, generateQL, generateRowCountQL, generateSelectClause, generateSimpleAllOrSome, generateSubquery, generateWhereClause, getAlias, getFilterFromExample, getFilterFromExample, getMetadataUtil, getPathRef, negate, param, prepareValue, securityCheckProperty, setRootAlias, splitPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPASearchProcessor

public JPASearchProcessor(MetadataUtil mdu)
Method Detail

search

public java.util.List search(javax.persistence.EntityManager entityManager,
                             ISearch search)
Search for objects based on the search parameters in the specified ISearch object.

See Also:
ISearch

search

public java.util.List search(javax.persistence.EntityManager entityManager,
                             java.lang.Class<?> searchClass,
                             ISearch search)
Search for objects based on the search parameters in the specified ISearch object. Uses the specified searchClass, ignoring the searchClass specified on the search itself.

See Also:
ISearch

count

public int count(javax.persistence.EntityManager entityManager,
                 ISearch search)
Returns the total number of results that would be returned using the given ISearch if there were no paging or maxResult limits.

See Also:
ISearch

count

public int count(javax.persistence.EntityManager entityManager,
                 java.lang.Class<?> searchClass,
                 ISearch search)
Returns the total number of results that would be returned using the given ISearch if there were no paging or maxResult limits. Uses the specified searchClass, ignoring the searchClass specified on the search itself.

See Also:
ISearch

searchAndCount

public SearchResult searchAndCount(javax.persistence.EntityManager entityManager,
                                   ISearch search)
Returns a SearchResult object that includes the list of results like search() and the total length like searchLength.

See Also:
ISearch

searchAndCount

public SearchResult searchAndCount(javax.persistence.EntityManager entityManager,
                                   java.lang.Class<?> searchClass,
                                   ISearch search)
Returns a SearchResult object that includes the list of results like search() and the total length like searchLength. Uses the specified searchClass, ignoring the searchClass specified on the search itself.

See Also:
ISearch

searchUnique

public java.lang.Object searchUnique(javax.persistence.EntityManager entityManager,
                                     ISearch search)
                              throws javax.persistence.NonUniqueResultException
Search for a single result using the given parameters.

Throws:
javax.persistence.NonUniqueResultException

searchUnique

public java.lang.Object searchUnique(javax.persistence.EntityManager entityManager,
                                     java.lang.Class<?> entityClass,
                                     ISearch search)
                              throws javax.persistence.NonUniqueResultException
Search for a single result using the given parameters. Uses the specified searchClass, ignoring the searchClass specified on the search itself.

Throws:
javax.persistence.NonUniqueResultException


Copyright © 2008-2010 eBM WebSourcing. All Rights Reserved.