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.
Modifier and Type | Field and Description |
---|---|
protected javax.persistence.EntityManager |
entityManager |
protected JPASearchProcessor |
processor |
Constructor and Description |
---|
JPASearchFacade() |
Modifier and Type | Method and Description |
---|---|
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) |
protected JPASearchProcessor processor
protected javax.persistence.EntityManager entityManager
public void setSearchProcessor(JPASearchProcessor searchProcessor)
public void setEntityManager(javax.persistence.EntityManager entityManager)
public java.util.List search(ISearch search)
SearchFacade
ISearch
object.search
in interface SearchFacade
ISearch
public java.util.List search(java.lang.Class<?> searchClass, ISearch search)
SearchFacade
ISearch
object. Uses the specified searchClass, ignoring the
searchClass specified on the search itself.search
in interface SearchFacade
ISearch
public int count(ISearch search)
SearchFacade
ISearch
if there were no paging or maxResult limits.count
in interface SearchFacade
ISearch
public int count(java.lang.Class<?> searchClass, ISearch search)
SearchFacade
ISearch
if there were no paging or maxResult limits.
Uses the specified searchClass, ignoring the searchClass specified on the
search itself.count
in interface SearchFacade
ISearch
public SearchResult searchAndCount(ISearch search)
SearchFacade
SearchResult
object that includes the list of
results like search()
and the total length like
searchLength
.searchAndCount
in interface SearchFacade
ISearch
public SearchResult searchAndCount(java.lang.Class<?> searchClass, ISearch search)
SearchFacade
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.searchAndCount
in interface SearchFacade
ISearch
public java.lang.Object searchUnique(ISearch search)
SearchFacade
searchUnique
in interface SearchFacade
public java.lang.Object searchUnique(java.lang.Class<?> searchClass, ISearch search)
SearchFacade
searchUnique
in interface SearchFacade
public Filter getFilterFromExample(java.lang.Object example)
SearchFacade
getFilterFromExample
in interface SearchFacade
public Filter getFilterFromExample(java.lang.Object example, ExampleOptions options)
SearchFacade
getFilterFromExample
in interface SearchFacade