|
From: <fc...@us...> - 2008-06-09 16:47:50
|
Revision: 832
http://openutils.svn.sourceforge.net/openutils/?rev=832&view=rev
Author: fcarone
Date: 2008-06-09 09:47:53 -0700 (Mon, 09 Jun 2008)
Log Message:
-----------
[maven-release-plugin] copy for tag openutils-bshd5-2.0.4
Added Paths:
-----------
tags/openutils-bshd5-2.0.4/
tags/openutils-bshd5-2.0.4/pom.xml
tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java
tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java
Removed Paths:
-------------
tags/openutils-bshd5-2.0.4/pom.xml
tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java
tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java
Copied: tags/openutils-bshd5-2.0.4 (from rev 829, trunk/openutils-bshd5)
Deleted: tags/openutils-bshd5-2.0.4/pom.xml
===================================================================
--- trunk/openutils-bshd5/pom.xml 2008-06-08 11:47:36 UTC (rev 829)
+++ tags/openutils-bshd5-2.0.4/pom.xml 2008-06-09 16:47:53 UTC (rev 832)
@@ -1,108 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>net.sourceforge.openutils</groupId>
- <artifactId>openutils</artifactId>
- <version>8</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>openutils-bshd5</artifactId>
- <name>openutils base Spring-Hibernate DAO for java 5.0</name>
- <version>2.0.4-SNAPSHOT</version>
- <description>openutils base Spring-Hibernate DAO for java 5.0</description>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate</artifactId>
- <version>3.2.1.ga</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib-nodep</artifactId>
- <version>2.1_3</version>
- </dependency>
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.7.0</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- </dependency>
- </dependencies>
- <properties>
- <spring.version>2.5.3</spring.version>
- </properties>
-</project>
\ No newline at end of file
Copied: tags/openutils-bshd5-2.0.4/pom.xml (from rev 831, trunk/openutils-bshd5/pom.xml)
===================================================================
--- tags/openutils-bshd5-2.0.4/pom.xml (rev 0)
+++ tags/openutils-bshd5-2.0.4/pom.xml 2008-06-09 16:47:53 UTC (rev 832)
@@ -0,0 +1,114 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>net.sourceforge.openutils</groupId>
+ <artifactId>openutils</artifactId>
+ <version>8</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>openutils-bshd5</artifactId>
+ <name>openutils base Spring-Hibernate DAO for java 5.0</name>
+ <version>2.0.4</version>
+ <description>openutils base Spring-Hibernate DAO for java 5.0</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ <version>3.2.1.ga</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <version>2.1_3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.7.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <spring.version>2.5.3</spring.version>
+ </properties>
+
+ <scm>
+ <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-2.0.4</connection>
+ <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-bshd5-2.0.4</developerConnection>
+ <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-bshd5-2.0.4</url>
+ </scm>
+</project>
\ No newline at end of file
Deleted: tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java
===================================================================
--- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java 2008-06-08 11:47:36 UTC (rev 829)
+++ tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java 2008-06-09 16:47:53 UTC (rev 832)
@@ -1,254 +0,0 @@
-package it.openutils.dao.hibernate;
-
-import it.openutils.hibernate.example.FilterMetadata;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.Order;
-import org.hibernate.type.Type;
-
-
-/**
- * @author Fabrizio Giustina
- * @version $Id$
- * @param <T> Persistence class
- * @param <K> Object Key
- */
-public interface HibernateDAO<T extends Object, K extends Serializable>
-{
-
- /**
- * Execute a query.
- * @param query a query expressed in Hibernate's query language
- * @return a distinct list of instances (or arrays of instances)
- */
- List<T> find(String query);
-
- /**
- * Return all objects related to the implementation of this DAO with no filter.
- * @return a list of all instances
- */
- List<T> findAll();
-
- /**
- * Return all objects related to the implementation of this DAO with no filter.
- * @param orderProperties <code>desc</code> or <code>asc</code>
- * @return a list of all instances
- */
- List<T> findAll(final Order[] orderProperties);
-
- /**
- * Return all objects related to the implementation of this DAO with no filter.
- * @param orderProperties <code>desc</code> or <code>asc</code>
- * @param criteria Additional Criterion conditions
- * @return a list of all instances
- */
- List<T> findAll(final Order[] orderProperties, List<Criterion> criteria);
-
- /**
- * Execute a query.
- * @param query a query expressed in Hibernate's query language
- * @param obj filter value
- * @param type filter type
- * @return a distinct list of instances (or arrays of instances)
- */
- List<T> find(String query, Object obj, Type type);
-
- /**
- * Execute a query.
- * @param query a query expressed in Hibernate's query language
- * @param obj filter values
- * @param type filter types
- * @return a distinct list of instances (or arrays of instances)
- */
- List<T> find(final String query, final Object[] obj, final Type[] type);
-
- /**
- * 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
- * <ul>
- * <li>where a database trigger alters the object state upon insert or update
- * <li>after executing direct SQL (eg. a mass update) in the same session
- * <li>after inserting a <tt>Blob</tt> or <tt>Clob</tt>
- * </ul>
- * @param obj Object
- */
- void refresh(T obj);
-
- /**
- * Remove the given object from the Session cache.
- * @param obj Object
- */
- void evict(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 <tt>cascade="merge"</tt>.<br>
- * <br>
- * The semantics of this method are defined by JSR-220.
- * @param obj a detached instance with state to be copied
- * @return an updated persistent instance
- */
- T merge(T obj);
-
- /**
- * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @param maxResults maximum number of results
- * @param page result page (first result is maxResults * page)
- * @return list of objects
- */
- List<T> findFiltered(final T filter, final int maxResults, final int page);
-
- /**
- * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @param metadata filter metadata
- * @param maxResults maximum number of results
- * @param page result page (first result is maxResults * page)
- * @return list of objects
- */
- List<T> findFiltered(final T filter, Map<String, FilterMetadata> metadata, final int maxResults, final int page);
-
- /**
- * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @param customOrder order criterias
- * @param metadata filter metadata
- * @param maxResults maximum number of results
- * @param page result page (first result is maxResults * page)
- * @return list of objects
- */
- List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata,
- final int maxResults, final int page);
-
- /**
- * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @param customOrder order criterias
- * @param metadata filter metadata
- * @param maxResults maximum number of results
- * @param page result page (first result is maxResults * page)
- * @param additionalCriteria additional criteria
- * @return list of objects
- */
- List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata,
- final int maxResults, final int page, List<Criterion> additionalCriteria);
-
- /**
- * Return properties from all objects related to the implementation of this DAO filtered using properties of the
- * provided instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @param customOrder order criterias
- * @param metadata filter metadata
- * @param maxResults maximum number of results
- * @param page result page (first result is maxResults * page)
- * @param additionalCriteria additional criteria
- * @param properties properties to be returned
- * @return list of properties from all objects
- */
- List< ? > findFilteredProperties(final T filter, final Order[] customOrder,
- final Map<String, FilterMetadata> metadata, final int maxResults, final int page,
- List<Criterion> additionalCriteria, List<String> properties);
-
- /**
- * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @return list of objects
- */
- List<T> findFiltered(final T filter);
-
- /**
- * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @param orderProperties the name of the property used for ordering
- * @return list of objects
- */
- List<T> findFiltered(final T filter, final Order[] orderProperties);
-
- /**
- * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @param metadata filter metadata
- * @return list of objects
- */
- List<T> findFiltered(final T filter, Map<String, FilterMetadata> metadata);
-
- /**
- * Return the first object related to the implementation of this DAO filtered using properties of the provided
- * instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @return first object in the collection
- */
- T findFilteredFirst(final T filter);
-
- /**
- * Return the first object related to the implementation of this DAO filtered using properties of the provided
- * instance.
- * @param filter an instance of the object with the properties you whish to filter on.
- * @param criteria additional criterion
- * @return first object in the collection
- */
- T findFilteredFirst(final T filter, final List<Criterion> criteria);
-
- /**
- * 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.
- * @param key key
- * @return true if the object was successfully deleted, false otherwise
- */
- boolean delete(final K key);
-
- /**
- * Load object matching the given key and return it. Throw an exception if not found.
- * @param key serializable key
- * @return Object
- */
- T load(K key);
-
- /**
- * Load object matching the given key and return it. Lazy object will be initialized.
- * @param key serializable key
- * @return Object
- */
- T loadIfAvailable(K key);
-
- /**
- * Load object matching the given key and return it. Lazy object will be initialized.
- * @param key serializable key
- * @return Object
- */
- T get(K key);
-
- /**
- * 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.
- * @param obj Object
- */
- void saveOrUpdate(final 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.
- * @param obj a transient instance containing updated state
- */
- void update(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.)
- * @param obj Object
- * @return generated id
- */
- K save(T obj);
-
-}
Copied: tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java (from rev 830, trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java)
===================================================================
--- tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java (rev 0)
+++ tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAO.java 2008-06-09 16:47:53 UTC (rev 832)
@@ -0,0 +1,262 @@
+package it.openutils.dao.hibernate;
+
+import it.openutils.hibernate.example.FilterMetadata;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.hibernate.type.Type;
+
+
+/**
+ * @author Fabrizio Giustina
+ * @version $Id$
+ * @param <T> Persistence class
+ * @param <K> Object Key
+ */
+public interface HibernateDAO<T extends Object, K extends Serializable>
+{
+
+ /**
+ * Execute a query.
+ * @param query a query expressed in Hibernate's query language
+ * @return a distinct list of instances (or arrays of instances)
+ */
+ List<T> find(String query);
+
+ /**
+ * Return all objects related to the implementation of this DAO with no filter.
+ * @return a list of all instances
+ */
+ List<T> findAll();
+
+ /**
+ * Return all objects related to the implementation of this DAO with no filter.
+ * @param orderProperties <code>desc</code> or <code>asc</code>
+ * @return a list of all instances
+ */
+ List<T> findAll(final Order[] orderProperties);
+
+ /**
+ * Return all objects related to the implementation of this DAO with no filter.
+ * @param orderProperties <code>desc</code> or <code>asc</code>
+ * @param criteria Additional Criterion conditions
+ * @return a list of all instances
+ */
+ List<T> findAll(final Order[] orderProperties, List<Criterion> criteria);
+
+ /**
+ * Execute a query.
+ * @param query a query expressed in Hibernate's query language
+ * @param obj filter value
+ * @param type filter type
+ * @return a distinct list of instances (or arrays of instances)
+ */
+ List<T> find(String query, Object obj, Type type);
+
+ /**
+ * Execute a query.
+ * @param query a query expressed in Hibernate's query language
+ * @param obj filter values
+ * @param type filter types
+ * @return a distinct list of instances (or arrays of instances)
+ */
+ List<T> find(final String query, final Object[] obj, final Type[] type);
+
+ /**
+ * 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
+ * <ul>
+ * <li>where a database trigger alters the object state upon insert or update
+ * <li>after executing direct SQL (eg. a mass update) in the same session
+ * <li>after inserting a <tt>Blob</tt> or <tt>Clob</tt>
+ * </ul>
+ * @param obj Object
+ */
+ void refresh(T obj);
+
+ /**
+ * Remove the given object from the Session cache.
+ * @param obj Object
+ */
+ void evict(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 <tt>cascade="merge"</tt>.<br>
+ * <br>
+ * The semantics of this method are defined by JSR-220.
+ * @param obj a detached instance with state to be copied
+ * @return an updated persistent instance
+ */
+ T merge(T obj);
+
+ /**
+ * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @param maxResults maximum number of results
+ * @param page result page (first result is maxResults * page)
+ * @return list of objects
+ */
+ List<T> findFiltered(final T filter, final int maxResults, final int page);
+
+ /**
+ * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @param metadata filter metadata
+ * @param maxResults maximum number of results
+ * @param page result page (first result is maxResults * page)
+ * @return list of objects
+ */
+ List<T> findFiltered(final T filter, Map<String, FilterMetadata> metadata, final int maxResults, final int page);
+
+ /**
+ * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @param customOrder order criterias
+ * @param metadata filter metadata
+ * @param maxResults maximum number of results
+ * @param page result page (first result is maxResults * page)
+ * @return list of objects
+ */
+ List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata,
+ final int maxResults, final int page);
+
+ /**
+ * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @param customOrder order criterias
+ * @param metadata filter metadata
+ * @param maxResults maximum number of results
+ * @param page result page (first result is maxResults * page)
+ * @param additionalCriteria additional criteria
+ * @return list of objects
+ */
+ List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata,
+ final int maxResults, final int page, List<Criterion> additionalCriteria);
+
+ /**
+ * Return properties from all objects related to the implementation of this DAO filtered using properties of the
+ * provided instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @param customOrder order criterias
+ * @param metadata filter metadata
+ * @param maxResults maximum number of results
+ * @param page result page (first result is maxResults * page)
+ * @param additionalCriteria additional criteria
+ * @param properties properties to be returned
+ * @return list of properties from all objects
+ */
+ List< ? > findFilteredProperties(final T filter, final Order[] customOrder,
+ final Map<String, FilterMetadata> metadata, final int maxResults, final int page,
+ List<Criterion> additionalCriteria, List<String> properties);
+
+ /**
+ * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @return list of objects
+ */
+ List<T> findFiltered(final T filter);
+
+ /**
+ * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @param orderProperties the name of the property used for ordering
+ * @return list of objects
+ */
+ List<T> findFiltered(final T filter, final Order[] orderProperties);
+
+ /**
+ * Return all objects related to the implementation of this DAO filtered using properties of the provided instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @param metadata filter metadata
+ * @return list of objects
+ */
+ List<T> findFiltered(final T filter, Map<String, FilterMetadata> metadata);
+
+ /**
+ * Return the first object related to the implementation of this DAO filtered using properties of the provided
+ * instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @return first object in the collection
+ */
+ T findFilteredFirst(final T filter);
+
+ /**
+ * Return the first object related to the implementation of this DAO filtered using properties of the provided
+ * instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @return first object in the collection
+ */
+ T findFilteredFirst(final T filter, final Order[] order);
+
+ /**
+ * Return the first object related to the implementation of this DAO filtered using properties of the provided
+ * instance.
+ * @param filter an instance of the object with the properties you whish to filter on.
+ * @param criteria additional criterion
+ * @return first object in the collection
+ */
+ T findFilteredFirst(final T filter, final List<Criterion> criteria);
+
+ /**
+ * 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.
+ * @param key key
+ * @return true if the object was successfully deleted, false otherwise
+ */
+ boolean delete(final K key);
+
+ /**
+ * Load object matching the given key and return it. Throw an exception if not found.
+ * @param key serializable key
+ * @return Object
+ */
+ T load(K key);
+
+ /**
+ * Load object matching the given key and return it. Lazy object will be initialized.
+ * @param key serializable key
+ * @return Object
+ */
+ T loadIfAvailable(K key);
+
+ /**
+ * Load object matching the given key and return it. Lazy object will be initialized.
+ * @param key serializable key
+ * @return Object
+ */
+ T get(K key);
+
+ /**
+ * 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.
+ * @param obj Object
+ */
+ void saveOrUpdate(final 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.
+ * @param obj a transient instance containing updated state
+ */
+ void update(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.)
+ * @param obj Object
+ * @return generated id
+ */
+ K save(T obj);
+
+}
Deleted: tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java
===================================================================
--- trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2008-06-08 11:47:36 UTC (rev 829)
+++ tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2008-06-09 16:47:53 UTC (rev 832)
@@ -1,674 +0,0 @@
-package it.openutils.dao.hibernate;
-
-import it.openutils.hibernate.example.EnhancedExample;
-import it.openutils.hibernate.example.FilterMetadata;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.aopalliance.aop.AspectException;
-import org.hibernate.Criteria;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.ObjectNotFoundException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.criterion.CriteriaSpecification;
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.ProjectionList;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Property;
-import org.hibernate.type.Type;
-import org.springframework.aop.framework.AopContext;
-import org.springframework.orm.hibernate3.HibernateCallback;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-
-/**
- * Base Hibernate DAO.
- * @author Fabrizio Giustina
- * @version $Id$
- * @param <T> Persistence class
- * @param <K> Object Key
- */
-public abstract class HibernateDAOImpl<T extends Object, K extends Serializable> extends HibernateDaoSupport
- implements
- HibernateDAO<T, K>
-{
-
- private Class<T> referenceClass;
-
- private boolean aopenabled;
-
- /**
- * Instantiates a new DAO instance
- */
- public HibernateDAOImpl()
- {
- super();
- }
-
- /**
- * Sets the class of the persistent bean managed by this DAO
- * @param referenceClass the class for the bean managed by this DAO
- */
- @SuppressWarnings({"unchecked" })
- public HibernateDAOImpl(Class referenceClass)
- {
- super();
- this.referenceClass = referenceClass;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public List<T> find(String query)
- {
- return getHibernateTemplate().find(query);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<T> findAll()
- {
- return findAll(getDefaultOrder());
- }
-
- /**
- * {@inheritDoc}
- */
- public List<T> findAll(final Order[] orderProperties)
- {
- return getThis().findAll(orderProperties, new ArrayList<Criterion>());
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public List<T> findAll(final Order[] orderProperties, final List<Criterion> criteria)
- {
- return (List<T>) getHibernateTemplate().execute(new HibernateCallback()
- {
-
- public Object doInHibernate(Session ses) throws HibernateException
- {
- Criteria crit = ses.createCriteria(getReferenceClass());
- if (null != orderProperties)
- {
- for (int j = 0; j < orderProperties.length; j++)
- {
- crit.addOrder(orderProperties[j]);
- }
-
- }
- if (criteria != null)
- {
- for (Criterion criterion : criteria)
- {
- crit.add(criterion);
- }
- }
- return crit.list();
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- public List<T> find(String query, Object obj, Type type)
- {
- return find(query, new Object[]{obj }, new Type[]{type });
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public List<T> find(final String query, final Object[] obj, final Type[] type)
- {
- return (List<T>) getHibernateTemplate().execute(new HibernateCallback()
- {
-
- public Object doInHibernate(Session ses) throws HibernateException
- {
- // hibernate 3
- return ses.createQuery(query).setParameters(obj, type).list();
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public T load(K key)
- {
- T result = (T) getHibernateTemplate().load(getReferenceClass(), key);
- Hibernate.initialize(result);
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public T loadIfAvailable(K key)
- {
- T result;
- try
- {
- result = (T) getHibernateTemplate().get(getReferenceClass(), key);
- if (result != null)
- {
- Hibernate.initialize(result);
- }
- }
- catch (ObjectNotFoundException e)
- {
- // during lazy initialization
- return null;
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public T get(K key)
- {
- return (T) getHibernateTemplate().get(getReferenceClass(), key);
- }
-
- /**
- * {@inheritDoc}
- */
- public void saveOrUpdate(final T obj)
- {
- getHibernateTemplate().saveOrUpdate(obj);
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(T obj)
- {
- getHibernateTemplate().update(obj);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean delete(final K key)
- {
-
- return (Boolean) getHibernateTemplate().execute(new HibernateCallback()
- {
-
- public Object doInHibernate(Session ses) throws HibernateException
- {
- ses.delete(ses.load(getReferenceClass(), key));
- return true;
- }
- });
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void refresh(T obj)
- {
- getHibernateTemplate().refresh(obj);
- }
-
- /**
- * {@inheritDoc}
- */
- public void evict(T obj)
- {
- getHibernateTemplate().evict(obj);
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public T merge(final T obj)
- {
- return (T) getHibernateTemplate().execute(new HibernateCallback()
- {
-
- public Object doInHibernate(Session ses) throws HibernateException
- {
- return ses.merge(obj);
- }
- });
-
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public K save(T obj)
- {
- return (K) getHibernateTemplate().save(obj);
- }
-
- /**
- * {@inheritDoc}
- */
- public T findFilteredFirst(final T filter)
- {
- return getFirstInCollection(findFiltered(filter, 1, 0));
- }
-
- /**
- * {@inheritDoc}
- */
- public T findFilteredFirst(final T filter, List<Criterion> criteria)
- {
- return getFirstInCollection(findFiltered(filter, null, getDefaultFilterMetadata(), 1, 0, criteria));
- }
-
- /**
- * {@inheritDoc}
- */
- public List<T> findFiltered(final T filter)
- {
- return findFiltered(filter, getDefaultFilterMetadata());
- }
-
- /**
- * {@inheritDoc}
- */
- public List<T> findFiltered(T filter, Order[] orderProperties)
- {
- return findFiltered(filter, orderProperties, getDefaultFilterMetadata(), Integer.MAX_VALUE, 0);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata)
- {
- return findFiltered(filter, metadata, Integer.MAX_VALUE, 0);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<T> findFiltered(final T filter, final int maxResults, final int page)
- {
- return findFiltered(filter, getDefaultFilterMetadata(), maxResults, page);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata, final int maxResults,
- final int page)
- {
- return findFiltered(filter, null, metadata, maxResults, page);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata,
- final int maxResults, final int page)
- {
- return getThis().findFiltered(filter, customOrder, metadata, maxResults, page, new ArrayList<Criterion>());
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public List<T> findFiltered(T filter, Order[] customOrder, Map<String, FilterMetadata> metadata, int maxResults,
- int page, List<Criterion> additionalCriteria)
- {
- final Order[] orderProperties = customOrder != null && customOrder.length > 0 ? customOrder : this
- .getDefaultOrder();
-
- return (List<T>) getHibernateTemplate().execute(
- new HibernateCallbackForExecution(
- filter,
- page,
- maxResults,
- metadata,
- orderProperties,
- additionalCriteria,
- null));
- }
-
- /**
- * {@inheritDoc}
- */
- public List< ? > findFilteredProperties(final T filter, final Order[] customOrder,
- final Map<String, FilterMetadata> metadata, final int maxResults, final int page,
- List<Criterion> additionalCriteria, List<String> properties)
- {
- final Order[] orderProperties = customOrder != null && customOrder.length > 0 ? customOrder : this
- .getDefaultOrder();
-
- return (List< ? >) getHibernateTemplate().execute(
- new HibernateCallbackForExecution(
- filter,
- page,
- maxResults,
- metadata,
- orderProperties,
- additionalCriteria,
- properties));
- }
-
- /**
- * Return the specific Object class that will be used for class-specific implementation of this DAO.
- * @return the reference Class
- */
- protected Class<T> getReferenceClass()
- {
- return referenceClass;
- }
-
- public void setReferenceClass(Class<T> referenceClass)
- {
- this.referenceClass = referenceClass;
- }
-
- /**
- * Return a list of <code>Order</code> object to be used for the default ordering of the collection.
- * @return the property name
- */
- protected Order[] getDefaultOrder()
- {
- return new Order[0];
- }
-
- /**
- * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given.
- * @param name the name of a query defined externally
- * @param params the parameter array
- * @param maxResults max number of results
- * @return Query
- */
- protected List< ? > findByNamedQuery(final String name, final Serializable[] params, final Integer maxResults)
- {
- return (List< ? >) getHibernateTemplate().execute(new HibernateCallback()
- {
-
- public Object doInHibernate(Session ses) throws HibernateException
- {
- Query q = ses.getNamedQuery(name);
- if (maxResults != null)
- {
- q.setMaxResults(maxResults);
- }
- if (params != null)
- {
- for (int i = 0; i < params.length; i++)
- {
- q.setParameter(i, params[i]);
- }
- }
- return q.list();
- }
- });
- }
-
- /**
- * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given.
- * @param name the name of a query defined externally
- * @param params the parameter Map
- * @param maxResults max number of results
- * @return Query
- */
- protected List< ? > findByNamedQuery(final String name, final Map<String, Object> params, final Integer maxResults)
- {
- return (List< ? >) getHibernateTemplate().execute(new HibernateCallback()
- {
-
- public Object doInHibernate(Session ses) throws HibernateException
- {
- Query q = ses.getNamedQuery(name);
- if (maxResults != null)
- {
- q.setMaxResults(maxResults);
- }
-
- if (params != null)
- {
- for (Map.Entry<String, Object> entry : params.entrySet())
- {
- setParameterValue(q, entry.getKey(), entry.getValue());
- }
- }
- return q.list();
- }
- });
- }
-
- /**
- * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given.
- * @param name the name of a query defined externally
- * @param params the parameter array
- * @param maxResults max number of results
- * @return Query
- * @deprecated use the better named <code>findByNamedQuery</code> method
- */
- @Deprecated
- protected List< ? > getNamedQuery(final String name, final Serializable[] params, int maxResults)
- {
- return findByNamedQuery(name, params, maxResults > 0 ? maxResults : Integer.MAX_VALUE);
- }
-
- /**
- * Obtain an instance of Query for a named query string defined in the mapping file. Use the parameters given.
- * @param name the name of a query defined externally
- * @param params the parameter Map
- * @param maxResults max number of results
- * @return Query
- * @deprecated use the better named <code>findByNamedQuery</code> method
- */
- @Deprecated
- protected List< ? > getNamedQuery(final String name, final Map<String, Object> params, int maxResults)
- {
- return findByNamedQuery(name, params, maxResults > 0 ? maxResults : Integer.MAX_VALUE);
- }
-
- /**
- * Convenience method to set paramers in the query given based on the actual object type in passed in as the value.
- * You may need to add more functionaly to this as desired (or not use this at all).
- * @param query the Query to set
- * @param key the key name
- * @param value the object to set as the parameter
- */
- protected void setParameterValue(Query query, String key, Object value)
- {
- if (null == key || null == value)
- {
- return;
- }
- query.setParameter(key, value);
- }
-
- /**
- * Returns the default set of FilterMetadata that will be applied to any query. The default implementation doesn't
- * set any default filter, subclasses may override this.
- * @return map of property name - filter metadata
- */
- protected Map<String, FilterMetadata> getDefaultFilterMetadata()
- {
- return new HashMap<String, FilterMetadata>(0);
- }
-
- /**
- * Returns the first object in the collection or null if the collection is null or empty.
- * @param list collection
- * @return first element in the list
- */
- @SuppressWarnings("unchecked")
- private T getFirstInCollection(Collection<T> list)
- {
- if (list != null && !list.isEmpty())
- {
- Object result = list.iterator().next();
- Hibernate.initialize(result);
- return (T) result;
- }
- return null;
- }
-
- /**
- * Sets the aopenabled.
- * @param aopenabled the aopenabled to set
- */
- public void setAopenabled(boolean aopenabled)
- {
- this.aopenabled = aopenabled;
- }
-
- /**
- * @return This is needed as for http://opensource.atlassian.com/projects/spring/browse/SPR-2226
- */
- @SuppressWarnings("unchecked")
- private HibernateDAO<T, K> getThis()
- {
- if (!aopenabled)
- {
- return this;
- }
-
- try
- {
- return (HibernateDAO<T, K>) AopContext.currentProxy();
- }
- catch (AspectException exc)
- {
- logger.debug("Not running inside an AOP proxy, so no proxy can be returned: " + exc.getMessage());
- return this;
- }
- catch (IllegalStateException e)
- {
- logger.warn("Cannot access proxy: " + e.getMessage());
- aopenabled = false;
- return this;
- }
- }
-
- /**
- * @author carone
- * @version $Id$
- */
- private final class HibernateCallbackForExecution implements HibernateCallback
- {
-
- /**
- *
- */
- private final T filter;
-
- /**
- *
- */
- private final int page;
-
- /**
- *
- */
- private final int maxResults;
-
- /**
- *
- */
- private final Map<String, FilterMetadata> metadata;
-
- /**
- *
- */
- private final List<String> properties;
-
- /**
- *
- */
- private final Order[] orderProperties;
-
- private List<Criterion> additionalCriteria;
-
- /**
- * @param filter
- * @param page
- * @param maxResults
- * @param metadata
- * @param orderProperties
- */
- private HibernateCallbackForExecution(
- T filter,
- int page,
- int maxResults,
- Map<String, FilterMetadata> metadata,
- Order[] orderProperties,
- List<Criterion> additionalCriteria,
- List<String> properties)
- {
- this.filter = filter;
- this.page = page;
- this.maxResults = maxResults;
- this.metadata = metadata;
- this.orderProperties = orderProperties;
- this.additionalCriteria = additionalCriteria;
- this.properties = properties;
- }
-
- public Object doInHibernate(Session ses) throws HibernateException
- {
- Criteria crit = ses.createCriteria(filter.getClass());
- crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
- crit.setMaxResults(maxResults);
- crit.setFirstResult(maxResults * page);
-
- if (orderProperties != null && orderProperties.length > 0)
- {
- for (Order order : orderProperties)
- {
- if (order != null)
- {
- crit.addOrder(order);
- }
- }
- }
- EnhancedExample.create(crit, filter, metadata);
- if (additionalCriteria != null && !additionalCriteria.isEmpty())
- {
- for (Criterion criterion : additionalCriteria)
- {
- crit.add(criterion);
- }
- }
- if (properties != null)
- {
- ProjectionList projectionList = Projections.projectionList();
-
- for (String property : properties)
- {
- projectionList.add(Property.forName(property));
- }
-
- crit.setProjection(projectionList);
- }
- return crit.list();
- }
- }
-
-}
\ No newline at end of file
Copied: tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java (from rev 830, trunk/openutils-bshd5/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java)
===================================================================
--- tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java (rev 0)
+++ tags/openutils-bshd5-2.0.4/src/main/java/it/openutils/dao/hibernate/HibernateDAOImpl.java 2008-06-09 16:47:53 UTC (rev 832)
@@ -0,0 +1,683 @@
+package it.openutils.dao.hibernate;
+
+import it.openutils.hibernate.example.EnhancedExample;
+import it.openutils.hibernate.example.FilterMetadata;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.aopalliance.aop.AspectException;
+import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.ObjectNotFoundException;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.criterion.CriteriaSpecification;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.ProjectionList;
+import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.Property;
+import org.hibernate.type.Type;
+import org.springframework.aop.framework.AopContext;
+import org.springframework.orm.hibernate3.HibernateCallback;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+
+/**
+ * Base Hibernate DAO.
+ * @author Fabrizio Giustina
+ * @version $Id$
+ * @param <T> Persistence class
+ * @param <K> Object Key
+ */
+public abstract class HibernateDAOImpl<T extends Object, K extends Serializable> extends HibernateDaoSupport
+ implements
+ HibernateDAO<T, K>
+{
+
+ private Class<T> referenceClass;
+
+ private boolean aopenabled;
+
+ /**
+ * Instantiates a new DAO instance
+ */
+ public HibernateDAOImpl()
+ {
+ super();
+ }
+
+ /**
+ * Sets the class of the persistent bean managed by this DAO
+ * @param referenceClass the class for the bean managed by this DAO
+ */
+ @SuppressWarnings({"unchecked" })
+ public HibernateDAOImpl(Class referenceClass)
+ {
+ super();
+ this.referenceClass = referenceClass;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public List<T> find(String query)
+ {
+ return getHibernateTemplate().find(query);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<T> findAll()
+ {
+ return findAll(getDefaultOrder());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<T> findAll(final Order[] orderProperties)
+ {
+ return getThis().findAll(orderProperties, new ArrayList<Criterion>());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public List<T> findAll(final Order[] orderProperties, final List<Criterion> criteria)
+ {
+ return (List<T>) getHibernateTemplate().execute(new HibernateCallback()
+ {
+
+ public Object doInHibernate(Session ses) throws HibernateException
+ {
+ Criteria crit = ses.createCriteria(getReferenceClass());
+ if (null != orderProperties)
+ {
+ for (int j = 0; j < orderProperties.length; j++)
+ {
+ crit.addOrder(orderProperties[j]);
+ }
+
+ }
+ if (criteria != null)
+ {
+ for (Criterion criterion : criteria)
+ {
+ crit.add(criterion);
+ }
+ }
+ return crit.list();
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<T> find(String query, Object obj, Type type)
+ {
+ return find(query, new Object[]{obj }, new Type[]{type });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public List<T> find(final String query, final Object[] obj, final Type[] type)
+ {
+ return (List<T>) getHibernateTemplate().execute(new HibernateCallback()
+ {
+
+ public Object doInHibernate(Session ses) throws HibernateException
+ {
+ // hibernate 3
+ return ses.createQuery(query).setParameters(obj, type).list();
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public T load(K key)
+ {
+ T result = (T) getHibernateTemplate().load(getReferenceClass(), key);
+ Hibernate.initialize(result);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public T loadIfAvailable(K key)
+ {
+ T result;
+ try
+ {
+ result = (T) getHibernateTemplate().get(getReferenceClass(), key);
+ if (result != null)
+ {
+ Hibernate.initialize(result);
+ }
+ }
+ catch (ObjectNotFoundException e)
+ {
+ // during lazy initialization
+ return null;
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public T get(K key)
+ {
+ return (T) getHibernateTemplate().get(getReferenceClass(), key);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void saveOrUpdate(final T obj)
+ {
+ getHibernateTemplate().saveOrUpdate(obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(T obj)
+ {
+ getHibernateTemplate().update(obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean delete(final K key)
+ {
+
+ return (Boolean) getHibernateTemplate().execute(new HibernateCallback()
+ {
+
+ public Object doInHibernate(Session ses) throws HibernateException
+ {
+ ses.delete(ses.load(getReferenceClass(), key));
+ return true;
+ }
+ });
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void refresh(T obj)
+ {
+ getHibernateTemplate().refresh(obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void evict(T obj)
+ {
+ getHibernateTemplate().evict(obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public T merge(final T obj)
+ {
+ return (T) getHibernateTemplate().execute(new HibernateCallback()
+ {
+
+ public Object doInHibernate(Session ses) throws HibernateException
+ {
+ return ses.merge(obj);
+ }
+ });
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public K save(T obj)
+ {
+ return (K) getHibernateTemplate().save(obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T findFilteredFirst(final T filter)
+ {
+ return getFirstInCollection(findFiltered(filter, 1, 0));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T findFilteredFirst(final T filter, final Order[] order)
+ {
+ return getFirstInCollection(findFiltered(filter, order, getDefaultFilterMetadata(), 1, 0));
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public T findFilteredFirst(final T filter, List<Criterion> criteria)
+ {
+ return getFirstInCollection(findFiltered(filter, null, getDefaultFilterMetadata(), 1, 0, criteria));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<T> findFiltered(final T filter)
+ {
+ return findFiltered(filter, getDefaultFilterMetadata());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<T> findFiltered(T filter, Order[] orderProperties)
+ {
+ return findFiltered(filter, orderProperties, getDefaultFilterMetadata(), Integer.MAX_VALUE, 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata)
+ {
+ return findFiltered(filter, metadata, Integer.MAX_VALUE, 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<T> findFiltered(final T filter, final int maxResults, final int page)
+ {
+ return findFiltered(filter, getDefaultFilterMetadata(), maxResults, page);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<T> findFiltered(final T filter, final Map<String, FilterMetadata> metadata, final int maxResults,
+ final int page)
+ {
+ return findFiltered(filter, null, metadata, maxResults, page);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<T> findFiltered(final T filter, final Order[] customOrder, final Map<String, FilterMetadata> metadata,
+ final int maxResults, final int page)
+ {
+ return getThis().findFiltered(filter, customOrder, metadata, maxResults, page, new ArrayList<Criterion>());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public List...
[truncated message content] |