com.trg.search.jpa
Class JPASearchFacade

java.lang.Object
  extended by com.trg.search.jpa.JPASearchFacade
All Implemented Interfaces:
SearchFacade

public class JPASearchFacade
extends java.lang.Object
implements SearchFacade

JPA implementation of SearchFacade.

The SearchProcessor and EntityManager must be set in order for the SearchFacade to function. Generally, a single SearchProcessor will be associated with an instance of JPASearchFacade for the lifetime of the instance, while a new "current" EntityManager will be injected as needed. Make sure that any EntityManager that is used is associated with the same persistence unit (i.e. EntityManagerFactory) as the SearchProcessor.

Author:
dwolverton

Field Summary
protected  javax.persistence.EntityManager entityManager
           
protected  JPASearchProcessor processor
           
 
Constructor Summary
JPASearchFacade()
           
 
Method Summary
 int count(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(ISearch search)
          Returns the total number of results that would be returned using the given ISearch if there were no paging or maxResult limits.
 Filter getFilterFromExample(java.lang.Object example)
          Generates a search filter from the given example using default options.
 Filter getFilterFromExample(java.lang.Object example, ExampleOptions options)
          Generates a search filter from the given example using the specified options.
 java.util.List search(java.lang.Class<?> searchClass, ISearch search)
          Search for objects based on the search parameters in the specified ISearch object.
 java.util.List search(ISearch search)
          Search for objects based on the search parameters in the specified ISearch object.
 SearchResult searchAndCount(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(ISearch search)
          Returns a SearchResult object that includes the list of results like search() and the total length like searchLength.
 java.lang.Object searchUnique(java.lang.Class<?> searchClass, ISearch search)
          Search for a single result using the given parameters.
 java.lang.Object searchUnique(ISearch search)
          Search for a single result using the given parameters.
 void setEntityManager(javax.persistence.EntityManager entityManager)
           
 void setSearchProcessor(JPASearchProcessor searchProcessor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

processor

protected JPASearchProcessor processor

entityManager

protected javax.persistence.EntityManager entityManager
Constructor Detail

JPASearchFacade

public JPASearchFacade()
Method Detail

setSearchProcessor

public void setSearchProcessor(JPASearchProcessor searchProcessor)

setEntityManager

public void setEntityManager(javax.persistence.EntityManager entityManager)

search

public java.util.List search(ISearch search)
Description copied from interface: SearchFacade
Search for objects based on the search parameters in the specified ISearch object.

Specified by:
search in interface SearchFacade
See Also:
ISearch

search

public java.util.List search(java.lang.Class<?> searchClass,
                             ISearch search)
Description copied from interface: SearchFacade
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.

Specified by:
search in interface SearchFacade
See Also:
ISearch

count

public int count(ISearch search)
Description copied from interface: SearchFacade
Returns the total number of results that would be returned using the given ISearch if there were no paging or maxResult limits.

Specified by:
count in interface SearchFacade
See Also:
ISearch

count

public int count(java.lang.Class<?> searchClass,
                 ISearch search)
Description copied from interface: SearchFacade
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.

Specified by:
count in interface SearchFacade
See Also:
ISearch

searchAndCount

public SearchResult searchAndCount(ISearch search)
Description copied from interface: SearchFacade
Returns a SearchResult object that includes the list of results like search() and the total length like searchLength.

Specified by:
searchAndCount in interface SearchFacade
See Also:
ISearch

searchAndCount

public SearchResult searchAndCount(java.lang.Class<?> searchClass,
                                   ISearch search)
Description copied from interface: SearchFacade
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.

Specified by:
searchAndCount in interface SearchFacade
See Also:
ISearch

searchUnique

public java.lang.Object searchUnique(ISearch search)
Description copied from interface: SearchFacade
Search for a single result using the given parameters.

Specified by:
searchUnique in interface SearchFacade

searchUnique

public java.lang.Object searchUnique(java.lang.Class<?> searchClass,
                                     ISearch search)
Description copied from interface: SearchFacade
Search for a single result using the given parameters. Uses the specified searchClass, ignoring the searchClass specified on the search itself.

Specified by:
searchUnique in interface SearchFacade

getFilterFromExample

public Filter getFilterFromExample(java.lang.Object example)
Description copied from interface: SearchFacade
Generates a search filter from the given example using default options.

Specified by:
getFilterFromExample in interface SearchFacade

getFilterFromExample

public Filter getFilterFromExample(java.lang.Object example,
                                   ExampleOptions options)
Description copied from interface: SearchFacade
Generates a search filter from the given example using the specified options.

Specified by:
getFilterFromExample in interface SearchFacade


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