it.openutils.dao.hibernate
Interface HibernateDAO<T,K extends Serializable>

Type Parameters:
T - the persistence entity class that this DAO will handle
K - the class of T's id property
All Known Implementing Classes:
HibernateDAOImpl

public interface HibernateDAO<T,K extends Serializable>

Version:
$Id: HibernateDAO.java 3499 2011-06-04 08:01:45Z fgiust $
Author:
Fabrizio Giustina

Method Summary
 boolean delete(K key)
          Used by the base DAO classes but here for your modification.
 void evict(T obj)
          Remove the given object from the Session cache.
 List<T> find(List<? extends org.hibernate.criterion.Criterion> criteria, org.hibernate.criterion.Order... orders)
          Retrieve the entities handled by this DAO that match the input criteria, ordered according to the input orders.
 List<T> find(String query)
          Retrieve all entities handled by this DAO that match the input query string.
 List<T> find(String query, Object[] paramValues, org.hibernate.type.Type[] paramTypes)
          Retrieve all entities handled by this DAO that match the input query string, accepting one query parameter and the corresponding type.
 List<T> find(String query, Object paramValue, org.hibernate.type.Type paramType)
          Retrieve all entities handled by this DAO that match the input query string, accepting one query parameter and the corresponding type.
 List<T> findAll()
          Retrieve all entities handled by this DAO, in no particular order.
 List<T> findAll(org.hibernate.criterion.Order... orders)
          Retrieve all entities handled by this DAO, ordered according to the input orders.
 List<T> findAll(org.hibernate.criterion.Order[] orderProperties, List<? extends org.hibernate.criterion.Criterion> criteria)
          Deprecated. use the correctly named #find(Order[], List) instead
 List<T> findFiltered(T filter)
          Retrieve the entities handled by this DAO whose property values match, via equals(), filter's non-null property values.
 List<T> findFiltered(T filter, int maxResults, int page)
          Retrieve the entities handled by this DAO whose property values match, via equals(), filter's non-null property values.
 List<T> findFiltered(T filter, Map<String,? extends FilterMetadata> metadata)
          Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values.
 List<T> findFiltered(T filter, Map<String,? extends FilterMetadata> metadata, int maxResults, int page)
          Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values.
 List<T> findFiltered(T filter, Map<String,? extends FilterMetadata> metadata, int maxResults, int page, List<? extends org.hibernate.criterion.Criterion> criteria, org.hibernate.criterion.Order... orders)
          Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values, and the input criteria.
 List<T> findFiltered(T filter, Map<String,? extends FilterMetadata> metadata, int maxResults, int page, org.hibernate.criterion.Order... orders)
          Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values.
 List<T> findFiltered(T filter, org.hibernate.criterion.Order... orders)
          Retrieve the entities handled by this DAO whose property values match, via equals(), filter's non-null property values.
 List<T> findFiltered(T filter, org.hibernate.criterion.Order[] orders, Map<String,? extends FilterMetadata> metadata, int maxResults, int page)
          Deprecated. superseded by findFiltered(Object, Map, int, int, Order...)
 List<T> findFiltered(T filter, org.hibernate.criterion.Order[] orders, Map<String,? extends FilterMetadata> metadata, int maxResults, int page, List<? extends org.hibernate.criterion.Criterion> criteria)
          Deprecated. superseded by findFiltered(Object, Map, int, int, List, Order...)
 T findFilteredFirst(T filter)
          Retrieve the first entity instance that matches the input filter, if existing.
 T findFilteredFirst(T filter, List<? extends org.hibernate.criterion.Criterion> criteria)
          Retrieve the first entity instance that matches the input filter and the additional input criteria, if existing.
 T findFilteredFirst(T filter, org.hibernate.criterion.Order... orders)
          Retrieve the first entity instance that matches the input filter, if existing.
 List<?> findFilteredProperties(T filter, Map<String,? extends FilterMetadata> metadata, int maxResults, int page, List<? extends org.hibernate.criterion.Criterion> criteria, List<String> properties, org.hibernate.criterion.Order... orders)
          Retrieve a set of properties from the entities returned by findFiltered(Object, Order[], Map, int, int, List)
 List<?> findFilteredProperties(T filter, org.hibernate.criterion.Order[] orders, Map<String,? extends FilterMetadata> metadata, int maxResults, int page, List<? extends org.hibernate.criterion.Criterion> criteria, List<String> properties)
          Deprecated. superseded by findFilteredProperties(Object, Map, int, int, List, List, Order...)
 T get(K key)
          Load object matching the given key and return it.
 T load(K key)
          Load object matching the given key and return it.
 T loadIfAvailable(K key)
          Load object matching the given key and return it.
 T merge(T obj)
          Copies the state of the given object onto the persistent object with the same identifier, and returns the updated persistent instance.
 void refresh(T obj)
          Re-reads the state of the given instance from the underlying database.
 K save(T obj)
          Persist the given transient instance, first assigning a generated identifier.
 void saveOrUpdate(T obj)
          Used by the base DAO classes but here for your modification Either save() or update() the given instance, depending upon the value of its identifier property.
 void update(T obj)
          Used by the base DAO classes but here for your modification Update the persistent state associated with the given identifier.
 

Method Detail

findAll

List<T> findAll()
Retrieve all entities handled by this DAO, in no particular order.

Returns:
the list of all entity instances (never null)

findAll

List<T> findAll(org.hibernate.criterion.Order... orders)
Retrieve all entities handled by this DAO, ordered according to the input orders.

Parameters:
orders - the orders to apply with respect to entity class properties
Returns:
the list of all entity instances (never null), ordered accordingly

find

List<T> find(String query)
Retrieve all entities handled by this DAO that match the input query string.

Parameters:
query - an HQL query
Returns:
a list of distinct entity instances (never null)

find

List<T> find(String query,
             Object paramValue,
             org.hibernate.type.Type paramType)
Retrieve all entities handled by this DAO that match the input query string, accepting one query parameter and the corresponding type.

Parameters:
query - an HQL query
paramValue - the value of a parameter to be set in the query
paramType - the Hibernate type of paramValue
Returns:
a list of distinct entity instances (never null)

find

List<T> find(String query,
             Object[] paramValues,
             org.hibernate.type.Type[] paramTypes)
Retrieve all entities handled by this DAO that match the input query string, accepting one query parameter and the corresponding type.

Parameters:
query - an HQL query
paramValues - the parameter values to be set in the query
paramTypes - the Hibernate types of paramValues
Returns:
a list of distinct entity instances (never null)

find

List<T> find(List<? extends org.hibernate.criterion.Criterion> criteria,
             org.hibernate.criterion.Order... orders)
Retrieve the entities handled by this DAO that match the input criteria, ordered according to the input orders.

Parameters:
criteria - a list of additional Hibernate criteria
orders - the orders to apply with respect to entity class properties
Returns:
a list of distinct entity instances (never null), matching the criteria and ordered accordingly

findFiltered

List<T> findFiltered(T filter)
Retrieve the entities handled by this DAO whose property values match, via equals(), filter's non-null property values.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
Returns:
a list of distinct entity instances (never null)

findFiltered

List<T> findFiltered(T filter,
                     org.hibernate.criterion.Order... orders)
Retrieve the entities handled by this DAO whose property values match, via equals(), filter's non-null property values. The result list is ordered according to the input orders parameter.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
orders - the orders to apply with respect to entity class properties
Returns:
a list of distinct entity instances (never null)

findFiltered

List<T> findFiltered(T filter,
                     int maxResults,
                     int page)
Retrieve the entities handled by this DAO whose property values match, via equals(), filter's non-null property values.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
maxResults - the maximum number of results to be fetched
page - the zero-based page number to use when displaying paginated results (the first entity returned is the one at position maxResults * page in the complete list of results), or 0 for no pagination
Returns:
a list of distinct entity instances (never null)

findFiltered

List<T> findFiltered(T filter,
                     Map<String,? extends FilterMetadata> metadata)
Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
metadata - a map that matches names of entity class properties to FilterMetadata modifiers, that will be used for comparing values of the corresponding property
Returns:
a list of distinct entity instances (never null)

findFiltered

List<T> findFiltered(T filter,
                     Map<String,? extends FilterMetadata> metadata,
                     int maxResults,
                     int page)
Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
metadata - a map that matches names of entity class properties to FilterMetadata modifiers, that will be used for comparing values of the corresponding property
maxResults - the maximum number of results to be fetched
page - the zero-based page number to use when displaying paginated results (the first entity returned is the one at position maxResults * page in the complete list of results), or 0 for no pagination
Returns:
a list of distinct entity instances (never null)

findFiltered

List<T> findFiltered(T filter,
                     Map<String,? extends FilterMetadata> metadata,
                     int maxResults,
                     int page,
                     org.hibernate.criterion.Order... orders)
Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values. The result list is ordered according to the orders parameter.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
metadata - a map that matches names of entity class properties to FilterMetadata modifiers, that will be used for comparing values of the corresponding property
maxResults - the maximum number of results to be fetched
page - the zero-based page number to use when displaying paginated results (the first entity returned is the one at position maxResults * page in the complete list of results), or 0 for no pagination
orders - the orders to apply with respect to entity class properties
Returns:
a list of distinct entity instances (never null)

findFiltered

List<T> findFiltered(T filter,
                     Map<String,? extends FilterMetadata> metadata,
                     int maxResults,
                     int page,
                     List<? extends org.hibernate.criterion.Criterion> criteria,
                     org.hibernate.criterion.Order... orders)
Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values, and the input criteria.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
metadata - a map that matches names of entity class properties to FilterMetadata modifiers, that will be used for comparing values of the corresponding property
maxResults - the maximum number of results to be fetched
page - the zero-based page number to use when displaying paginated results (the first entity returned is the one at position maxResults * page in the complete list of results), or 0 for no pagination
criteria - a list of additional Hibernate criteria
orders - the orders to apply with respect to entity class properties
Returns:
a list of distinct entity instances (never null)

findFilteredProperties

List<?> findFilteredProperties(T filter,
                               Map<String,? extends FilterMetadata> metadata,
                               int maxResults,
                               int page,
                               List<? extends org.hibernate.criterion.Criterion> criteria,
                               List<String> properties,
                               org.hibernate.criterion.Order... orders)
Retrieve a set of properties from the entities returned by findFiltered(Object, Order[], Map, int, int, List)

Parameters:
filter - an instance of this DAO's entity class to be used as filter
metadata - a map that matches names of entity class properties to FilterMetadata modifiers, that will be used for comparing values of the corresponding property
maxResults - the maximum number of results to be fetched
page - the zero-based page number to use when displaying paginated results (the first entity returned is the one at position maxResults * page in the complete list of results), or 0 for no pagination
criteria - a list of additional Hibernate criteria
properties - the names of the properties to return
orders - the orders to apply with respect to entity class properties
Returns:
a list of distinct entity instances (never null)

findFilteredFirst

T findFilteredFirst(T filter)
Retrieve the first entity instance that matches the input filter, if existing.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
Returns:
the first matching instance of the entity class managed by this DAO, or null if none found
See Also:
#findFiltered(T)

findFilteredFirst

T findFilteredFirst(T filter,
                    org.hibernate.criterion.Order... orders)
Retrieve the first entity instance that matches the input filter, if existing.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
orders - the orders to apply with respect to entity class properties
Returns:
the first matching instance of the entity class managed by this DAO, or null if none found
See Also:
#findFiltered(T, Order...)

findFilteredFirst

T findFilteredFirst(T filter,
                    List<? extends org.hibernate.criterion.Criterion> criteria)
Retrieve the first entity instance that matches the input filter and the additional input criteria, if existing.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
criteria - a list of additional Hibernate criteria
Returns:
the first matching instance of the entity class managed by this DAO, or null if none found
See Also:
#findFiltered(T, List)

load

T load(K key)
Load object matching the given key and return it. Throw an exception if not found.

Parameters:
key - the id of the entity instance to load
Returns:
the found entity instance (never null)

loadIfAvailable

T loadIfAvailable(K key)
Load object matching the given key and return it. Lazy object will be initialized.

Parameters:
key - the id of the entity instance to load
Returns:
the found entity instance, or null if none found

get

T get(K key)
Load object matching the given key and return it. Lazy object will be initialized.

Parameters:
key - the id of the entity instance to load
Returns:
the found entity instance (never null)

save

K save(T obj)
Persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.)

Parameters:
obj - the entity instance to save
Returns:
the id generated for the persisted instance

update

void update(T obj)
Used by the base DAO classes but here for your modification Update the persistent state associated with the given identifier. An exception is thrown if there is a persistent instance with the same identifier in the current session.

Parameters:
obj - a transient instance containing updated state

saveOrUpdate

void saveOrUpdate(T obj)
Used by the base DAO classes but here for your modification Either save() or update() the given instance, depending upon the value of its identifier property.

Parameters:
obj - Object

delete

boolean delete(K key)
Used by the base DAO classes but here for your modification. Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving Session or a transient instance with an identifier associated with existing persistent state.

Parameters:
key - key
Returns:
true if the object was successfully deleted, false otherwise

refresh

void refresh(T obj)
Re-reads the state of the given instance from the underlying database. This method is useful in certain special circumstances, for example: However, use of this method in long-running sessions that span many business tasks is discouraged.

Parameters:
obj - the entity instance to refresh

evict

void evict(T obj)
Remove the given object from the Session cache.

Parameters:
obj - the entity instance to remove

merge

T merge(T obj)
Copies the state of the given object onto the persistent object with the same identifier, and returns the updated persistent instance. If there is no persistent instance currently associated with the session, a new one will be loaded. If the given instance is unsaved, saves a copy of and return it as a newly persisted instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped with cascade="merge".

The semantics of this method are defined by JSR-220.

Parameters:
obj - a detached instance with state to be copied
Returns:
an updated persistent instance

findAll

@Deprecated
List<T> findAll(org.hibernate.criterion.Order[] orderProperties,
                           List<? extends org.hibernate.criterion.Criterion> criteria)
Deprecated. use the correctly named #find(Order[], List) instead

Return all objects related to the implementation of this DAO with no filter.

Parameters:
orderProperties - desc or asc
criteria - Additional Criterion conditions
Returns:
a list of all instances

findFiltered

@Deprecated
List<T> findFiltered(T filter,
                                org.hibernate.criterion.Order[] orders,
                                Map<String,? extends FilterMetadata> metadata,
                                int maxResults,
                                int page)
Deprecated. superseded by findFiltered(Object, Map, int, int, Order...)

Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values. The result list is ordered according to the orders parameter.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
orders - the orders to apply with respect to entity class properties
metadata - a map that matches names of entity class properties to FilterMetadata modifiers, that will be used for comparing values of the corresponding property
maxResults - the maximum number of results to be fetched
page - the zero-based page number to use when displaying paginated results (the first entity returned is the one at position maxResults * page in the complete list of results), or 0 for no pagination
Returns:
a list of distinct entity instances (never null)

findFiltered

@Deprecated
List<T> findFiltered(T filter,
                                org.hibernate.criterion.Order[] orders,
                                Map<String,? extends FilterMetadata> metadata,
                                int maxResults,
                                int page,
                                List<? extends org.hibernate.criterion.Criterion> criteria)
Deprecated. superseded by findFiltered(Object, Map, int, int, List, Order...)

Retrieve the entities handled by this DAO whose property values match, via equals() or via a specified FilterMetadata object, filter's non-null property values, and the input criteria.

Parameters:
filter - an instance of this DAO's entity class to be used as filter
orders - the orders to apply with respect to entity class properties
metadata - a map that matches names of entity class properties to FilterMetadata modifiers, that will be used for comparing values of the corresponding property
maxResults - the maximum number of results to be fetched
page - the zero-based page number to use when displaying paginated results (the first entity returned is the one at position maxResults * page in the complete list of results), or 0 for no pagination
criteria - a list of additional Hibernate criteria
Returns:
a list of distinct entity instances (never null)

findFilteredProperties

@Deprecated
List<?> findFilteredProperties(T filter,
                                          org.hibernate.criterion.Order[] orders,
                                          Map<String,? extends FilterMetadata> metadata,
                                          int maxResults,
                                          int page,
                                          List<? extends org.hibernate.criterion.Criterion> criteria,
                                          List<String> properties)
Deprecated. superseded by findFilteredProperties(Object, Map, int, int, List, List, Order...)

Retrieve a set of properties from the entities returned by findFiltered(Object, Order[], Map, int, int, List)

Parameters:
filter - an instance of this DAO's entity class to be used as filter
orders - the orders to apply with respect to entity class properties
metadata - a map that matches names of entity class properties to FilterMetadata modifiers, that will be used for comparing values of the corresponding property
maxResults - the maximum number of results to be fetched
page - the zero-based page number to use when displaying paginated results (the first entity returned is the one at position maxResults * page in the complete list of results), or 0 for no pagination
criteria - a list of additional Hibernate criteria
properties - the names of the properties to return
Returns:
a list of distinct entity instances (never null)


Copyright © 2005-2011 Openmind. All Rights Reserved.