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

Type Parameters:
T - Persistence class
K - Object Key
All Known Implementing Classes:
HibernateDAOImpl

public interface HibernateDAO<T,K extends java.io.Serializable>

Version:
$Id: HibernateDAO.java 1255 2009-08-12 14:26:58Z fgrilli $
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.
 java.util.List<T> find(java.lang.String query)
          Execute a query.
 java.util.List<T> find(java.lang.String query, java.lang.Object[] obj, org.hibernate.type.Type[] type)
          Execute a query.
 java.util.List<T> find(java.lang.String query, java.lang.Object obj, org.hibernate.type.Type type)
          Execute a query.
 java.util.List<T> findAll()
          Return all objects related to the implementation of this DAO with no filter.
 java.util.List<T> findAll(org.hibernate.criterion.Order[] orderProperties)
          Return all objects related to the implementation of this DAO with no filter.
 java.util.List<T> findAll(org.hibernate.criterion.Order[] orderProperties, java.util.List<org.hibernate.criterion.Criterion> criteria)
          Return all objects related to the implementation of this DAO with no filter.
 java.util.List<T> findFiltered(T filter)
          Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
 java.util.List<T> findFiltered(T filter, int maxResults, int page)
          Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
 java.util.List<T> findFiltered(T filter, java.util.Map<java.lang.String,FilterMetadata> metadata)
          Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
 java.util.List<T> findFiltered(T filter, java.util.Map<java.lang.String,FilterMetadata> metadata, int maxResults, int page)
          Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
 java.util.List<T> findFiltered(T filter, org.hibernate.criterion.Order[] orderProperties)
          Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
 java.util.List<T> findFiltered(T filter, org.hibernate.criterion.Order[] customOrder, java.util.Map<java.lang.String,FilterMetadata> metadata, int maxResults, int page)
          Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
 java.util.List<T> findFiltered(T filter, org.hibernate.criterion.Order[] customOrder, java.util.Map<java.lang.String,FilterMetadata> metadata, int maxResults, int page, java.util.List<org.hibernate.criterion.Criterion> additionalCriteria)
          Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
 T findFilteredFirst(T filter)
          Return the first object related to the implementation of this DAO filtered using properties of the provided instance.
 T findFilteredFirst(T filter, java.util.List<org.hibernate.criterion.Criterion> criteria)
          Return the first object related to the implementation of this DAO filtered using properties of the provided instance.
 T findFilteredFirst(T filter, org.hibernate.criterion.Order[] order)
          Return the first object related to the implementation of this DAO filtered using properties of the provided instance.
 java.util.List<?> findFilteredProperties(T filter, org.hibernate.criterion.Order[] customOrder, java.util.Map<java.lang.String,FilterMetadata> metadata, int maxResults, int page, java.util.List<org.hibernate.criterion.Criterion> additionalCriteria, java.util.List<java.lang.String> properties)
          Return properties from all objects related to the implementation of this DAO filtered using properties of the provided instance.
 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)
          Copy the state of the given object onto the persistent object with the same identifier.
 void refresh(T obj)
          Re-read 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

find

java.util.List<T> find(java.lang.String query)
Execute a query.

Parameters:
query - a query expressed in Hibernate's query language
Returns:
a distinct list of instances (or arrays of instances)

findAll

java.util.List<T> findAll()
Return all objects related to the implementation of this DAO with no filter.

Returns:
a list of all instances

findAll

java.util.List<T> findAll(org.hibernate.criterion.Order[] orderProperties)
Return all objects related to the implementation of this DAO with no filter.

Parameters:
orderProperties - desc or asc
Returns:
a list of all instances

findAll

java.util.List<T> findAll(org.hibernate.criterion.Order[] orderProperties,
                          java.util.List<org.hibernate.criterion.Criterion> criteria)
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

find

java.util.List<T> find(java.lang.String query,
                       java.lang.Object obj,
                       org.hibernate.type.Type type)
Execute a query.

Parameters:
query - a query expressed in Hibernate's query language
obj - filter value
type - filter type
Returns:
a distinct list of instances (or arrays of instances)

find

java.util.List<T> find(java.lang.String query,
                       java.lang.Object[] obj,
                       org.hibernate.type.Type[] type)
Execute a query.

Parameters:
query - a query expressed in Hibernate's query language
obj - filter values
type - filter types
Returns:
a distinct list of instances (or arrays of instances)

refresh

void refresh(T obj)
Re-read the state of the given instance from the underlying database. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances. For example

Parameters:
obj - Object

evict

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

Parameters:
obj - Object

merge

T merge(T obj)
Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy of and return it as a newly persistent 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

findFiltered

java.util.List<T> findFiltered(T filter,
                               int maxResults,
                               int page)
Return all objects related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
maxResults - maximum number of results
page - result page (first result is maxResults * page)
Returns:
list of objects

findFiltered

java.util.List<T> findFiltered(T filter,
                               java.util.Map<java.lang.String,FilterMetadata> metadata,
                               int maxResults,
                               int page)
Return all objects related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
metadata - filter metadata
maxResults - maximum number of results
page - result page (first result is maxResults * page)
Returns:
list of objects

findFiltered

java.util.List<T> findFiltered(T filter,
                               org.hibernate.criterion.Order[] customOrder,
                               java.util.Map<java.lang.String,FilterMetadata> metadata,
                               int maxResults,
                               int page)
Return all objects related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
customOrder - order criterias
metadata - filter metadata
maxResults - maximum number of results
page - result page (first result is maxResults * page)
Returns:
list of objects

findFiltered

java.util.List<T> findFiltered(T filter,
                               org.hibernate.criterion.Order[] customOrder,
                               java.util.Map<java.lang.String,FilterMetadata> metadata,
                               int maxResults,
                               int page,
                               java.util.List<org.hibernate.criterion.Criterion> additionalCriteria)
Return all objects related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
customOrder - order criterias
metadata - filter metadata
maxResults - maximum number of results
page - result page (first result is maxResults * page)
additionalCriteria - additional criteria
Returns:
list of objects

findFilteredProperties

java.util.List<?> findFilteredProperties(T filter,
                                         org.hibernate.criterion.Order[] customOrder,
                                         java.util.Map<java.lang.String,FilterMetadata> metadata,
                                         int maxResults,
                                         int page,
                                         java.util.List<org.hibernate.criterion.Criterion> additionalCriteria,
                                         java.util.List<java.lang.String> properties)
Return properties from all objects related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
customOrder - order criterias
metadata - filter metadata
maxResults - maximum number of results
page - result page (first result is maxResults * page)
additionalCriteria - additional criteria
properties - properties to be returned
Returns:
list of properties from all objects

findFiltered

java.util.List<T> findFiltered(T filter)
Return all objects related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
Returns:
list of objects

findFiltered

java.util.List<T> findFiltered(T filter,
                               org.hibernate.criterion.Order[] orderProperties)
Return all objects related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
orderProperties - the name of the property used for ordering
Returns:
list of objects

findFiltered

java.util.List<T> findFiltered(T filter,
                               java.util.Map<java.lang.String,FilterMetadata> metadata)
Return all objects related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
metadata - filter metadata
Returns:
list of objects

findFilteredFirst

T findFilteredFirst(T filter)
Return the first object related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
Returns:
first object in the collection

findFilteredFirst

T findFilteredFirst(T filter,
                    org.hibernate.criterion.Order[] order)
Return the first object related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
Returns:
first object in the collection

findFilteredFirst

T findFilteredFirst(T filter,
                    java.util.List<org.hibernate.criterion.Criterion> criteria)
Return the first object related to the implementation of this DAO filtered using properties of the provided instance.

Parameters:
filter - an instance of the object with the properties you wish to filter on.
criteria - additional criterion
Returns:
first object in the collection

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

load

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

Parameters:
key - serializable key
Returns:
Object

loadIfAvailable

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

Parameters:
key - serializable key
Returns:
Object

get

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

Parameters:
key - serializable key
Returns:
Object

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

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

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 - Object
Returns:
generated id


Copyright © 2009 Openmind. All Rights Reserved.