Browse files

Fixed all List return types to ? instead of Object, restoring backwar…

…ds compatibility with existing Spring 3.2.x based code and allowing easier casts to other element types

Also declaring findByExample generically based on the given example object's type.

Issue: SPR-11402
  • Loading branch information...
1 parent 919d6cc commit 99f9dce14a2f162466f6ee06943f644539e36f53 @jhoeller jhoeller committed Feb 7, 2014
View
33 ...-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/HibernateOperations.java
@@ -567,7 +567,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#createQuery
*/
- List<Object> find(String queryString, Object... values) throws DataAccessException;
+ List<?> find(String queryString, Object... values) throws DataAccessException;
/**
* Execute an HQL query, binding one value to a ":" named parameter
@@ -579,8 +579,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedParam(String queryString, String paramName, Object value)
- throws DataAccessException;
+ List<?> findByNamedParam(String queryString, String paramName, Object value) throws DataAccessException;
/**
* Execute an HQL query, binding a number of values to ":" named
@@ -592,8 +591,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedParam(String queryString, String[] paramNames, Object[] values)
- throws DataAccessException;
+ List<?> findByNamedParam(String queryString, String[] paramNames, Object[] values) throws DataAccessException;
/**
* Execute an HQL query, binding the properties of the given bean to
@@ -605,7 +603,7 @@
* @see org.hibernate.Query#setProperties
* @see org.hibernate.Session#createQuery
*/
- List<Object> findByValueBean(String queryString, Object valueBean) throws DataAccessException;
+ List<?> findByValueBean(String queryString, Object valueBean) throws DataAccessException;
//-------------------------------------------------------------------------
@@ -622,7 +620,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQuery(String queryName, Object... values) throws DataAccessException;
+ List<?> findByNamedQuery(String queryName, Object... values) throws DataAccessException;
/**
* Execute a named query, binding one value to a ":" named parameter
@@ -635,7 +633,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
+ List<?> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
throws DataAccessException;
/**
@@ -649,7 +647,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
+ List<?> findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
throws DataAccessException;
/**
@@ -663,8 +661,7 @@
* @see org.hibernate.Query#setProperties
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQueryAndValueBean(String queryName, Object valueBean)
- throws DataAccessException;
+ List<?> findByNamedQueryAndValueBean(String queryName, Object valueBean) throws DataAccessException;
//-------------------------------------------------------------------------
@@ -680,7 +677,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.criterion.DetachedCriteria#getExecutableCriteria(org.hibernate.Session)
*/
- List<Object> findByCriteria(DetachedCriteria criteria) throws DataAccessException;
+ List<?> findByCriteria(DetachedCriteria criteria) throws DataAccessException;
/**
* Execute a query based on the given Hibernate criteria object.
@@ -697,7 +694,7 @@
* @see org.hibernate.Criteria#setFirstResult(int)
* @see org.hibernate.Criteria#setMaxResults(int)
*/
- List<Object> findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults) throws DataAccessException;
+ List<?> findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults) throws DataAccessException;
/**
* Execute a query based on the given example entity object.
@@ -707,7 +704,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.criterion.Example#create(Object)
*/
- List<Object> findByExample(Object exampleEntity) throws DataAccessException;
+ <T> List<T> findByExample(T exampleEntity) throws DataAccessException;
/**
* Execute a query based on the given example entity object.
@@ -718,7 +715,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.criterion.Example#create(Object)
*/
- List<Object> findByExample(String entityName, Object exampleEntity) throws DataAccessException;
+ <T> List<T> findByExample(String entityName, T exampleEntity) throws DataAccessException;
/**
* Execute a query based on a given example entity object.
@@ -734,7 +731,7 @@
* @see org.hibernate.Criteria#setFirstResult(int)
* @see org.hibernate.Criteria#setMaxResults(int)
*/
- List<Object> findByExample(Object exampleEntity, int firstResult, int maxResults) throws DataAccessException;
+ <T> List<T> findByExample(T exampleEntity, int firstResult, int maxResults) throws DataAccessException;
/**
* Execute a query based on a given example entity object.
@@ -751,7 +748,7 @@
* @see org.hibernate.Criteria#setFirstResult(int)
* @see org.hibernate.Criteria#setMaxResults(int)
*/
- List<Object> findByExample(String entityName, Object exampleEntity, int firstResult, int maxResults)
+ <T> List<T> findByExample(String entityName, T exampleEntity, int firstResult, int maxResults)
throws DataAccessException;
@@ -771,7 +768,7 @@
* @see org.hibernate.Session#createQuery
* @see org.hibernate.Query#iterate
*/
- Iterator<Object> iterate(String queryString, Object... values) throws DataAccessException;
+ Iterator<?> iterate(String queryString, Object... values) throws DataAccessException;
/**
* Immediately close an {@link Iterator} created by any of the various
View
78 ...ng-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/HibernateTemplate.java
@@ -417,7 +417,7 @@ protected void disableFilters(Session session) {
return executeWithNativeSession(new HibernateCallback<T>() {
@Override
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings("unchecked")
public T doInHibernate(Session session) throws HibernateException {
if (lockMode != null) {
return (T) session.get(entityClass, id, new LockOptions(lockMode));
@@ -462,7 +462,7 @@ public Object doInHibernate(Session session) throws HibernateException {
return executeWithNativeSession(new HibernateCallback<T>() {
@Override
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings("unchecked")
public T doInHibernate(Session session) throws HibernateException {
if (lockMode != null) {
return (T) session.load(entityClass, id, new LockOptions(lockMode));
@@ -860,11 +860,11 @@ public Object doInHibernate(Session session) {
//-------------------------------------------------------------------------
@Override
- public List<Object> find(final String queryString, final Object... values) throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ public List<?> find(final String queryString, final Object... values) throws DataAccessException {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
prepareQuery(queryObject);
if (values != null) {
@@ -878,23 +878,23 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByNamedParam(String queryString, String paramName, Object value)
+ public List<?> findByNamedParam(String queryString, String paramName, Object value)
throws DataAccessException {
- return findByNamedParam(queryString, new String[]{paramName}, new Object[]{value});
+ return findByNamedParam(queryString, new String[] {paramName}, new Object[] {value});
}
@Override
- public List<Object> findByNamedParam(final String queryString, final String[] paramNames, final Object[] values)
+ public List<?> findByNamedParam(final String queryString, final String[] paramNames, final Object[] values)
throws DataAccessException {
if (paramNames.length != values.length) {
throw new IllegalArgumentException("Length of paramNames array must match length of values array");
}
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
prepareQuery(queryObject);
if (values != null) {
@@ -908,13 +908,13 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByValueBean(final String queryString, final Object valueBean)
+ public List<?> findByValueBean(final String queryString, final Object valueBean)
throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
prepareQuery(queryObject);
queryObject.setProperties(valueBean);
@@ -929,11 +929,11 @@ public Object doInHibernate(Session session) {
//-------------------------------------------------------------------------
@Override
- public List<Object> findByNamedQuery(final String queryName, final Object... values) throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ public List<?> findByNamedQuery(final String queryName, final Object... values) throws DataAccessException {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.getNamedQuery(queryName);
prepareQuery(queryObject);
if (values != null) {
@@ -947,24 +947,24 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
+ public List<?> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
throws DataAccessException {
- return findByNamedQueryAndNamedParam(queryName, new String[]{paramName}, new Object[]{value});
+ return findByNamedQueryAndNamedParam(queryName, new String[] {paramName}, new Object[] {value});
}
@Override
- public List<Object> findByNamedQueryAndNamedParam(
+ public List<?> findByNamedQueryAndNamedParam(
final String queryName, final String[] paramNames, final Object[] values)
throws DataAccessException {
if (values != null && (paramNames == null || paramNames.length != values.length)) {
throw new IllegalArgumentException("Length of paramNames array must match length of values array");
}
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.getNamedQuery(queryName);
prepareQuery(queryObject);
if (values != null) {
@@ -978,13 +978,13 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByNamedQueryAndValueBean(final String queryName, final Object valueBean)
+ public List<?> findByNamedQueryAndValueBean(final String queryName, final Object valueBean)
throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.getNamedQuery(queryName);
prepareQuery(queryObject);
queryObject.setProperties(valueBean);
@@ -999,19 +999,19 @@ public Object doInHibernate(Session session) {
//-------------------------------------------------------------------------
@Override
- public List<Object> findByCriteria(DetachedCriteria criteria) throws DataAccessException {
+ public List<?> findByCriteria(DetachedCriteria criteria) throws DataAccessException {
return findByCriteria(criteria, -1, -1);
}
@Override
- public List<Object> findByCriteria(final DetachedCriteria criteria, final int firstResult, final int maxResults)
+ public List<?> findByCriteria(final DetachedCriteria criteria, final int firstResult, final int maxResults)
throws DataAccessException {
Assert.notNull(criteria, "DetachedCriteria must not be null");
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Criteria executableCriteria = criteria.getExecutableCriteria(session);
prepareCriteria(executableCriteria);
if (firstResult >= 0) {
@@ -1026,30 +1026,30 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByExample(Object exampleEntity) throws DataAccessException {
+ public <T> List<T> findByExample(T exampleEntity) throws DataAccessException {
return findByExample(null, exampleEntity, -1, -1);
}
@Override
- public List<Object> findByExample(String entityName, Object exampleEntity) throws DataAccessException {
+ public <T> List<T> findByExample(String entityName, T exampleEntity) throws DataAccessException {
return findByExample(entityName, exampleEntity, -1, -1);
}
@Override
- public List<Object> findByExample(Object exampleEntity, int firstResult, int maxResults) throws DataAccessException {
+ public <T> List<T> findByExample(T exampleEntity, int firstResult, int maxResults) throws DataAccessException {
return findByExample(null, exampleEntity, firstResult, maxResults);
}
@Override
- public List<Object> findByExample(
- final String entityName, final Object exampleEntity, final int firstResult, final int maxResults)
+ public <T> List<T> findByExample(
+ final String entityName, final T exampleEntity, final int firstResult, final int maxResults)
throws DataAccessException {
Assert.notNull(exampleEntity, "Example entity must not be null");
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<T>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<T> doInHibernate(Session session) throws HibernateException {
Criteria executableCriteria = (entityName != null ?
session.createCriteria(entityName) : session.createCriteria(exampleEntity.getClass()));
executableCriteria.add(Example.create(exampleEntity));
@@ -1071,11 +1071,11 @@ public Object doInHibernate(Session session) {
//-------------------------------------------------------------------------
@Override
- public Iterator<Object> iterate(final String queryString, final Object... values) throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<Iterator<Object>>() {
+ public Iterator<?> iterate(final String queryString, final Object... values) throws DataAccessException {
+ return executeWithNativeSession(new HibernateCallback<Iterator<?>>() {
@Override
@SuppressWarnings("unchecked")
- public Iterator<Object> doInHibernate(Session session) throws HibernateException {
+ public Iterator<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
prepareQuery(queryObject);
if (values != null) {
@@ -1199,7 +1199,7 @@ protected void prepareCriteria(Criteria criteria) {
* @param queryObject the Query object
* @param paramName the name of the parameter
* @param value the value of the parameter
- * @throws org.hibernate.HibernateException if thrown by the Query object
+ * @throws HibernateException if thrown by the Query object
*/
protected void applyNamedParameterToQuery(Query queryObject, String paramName, Object value)
throws HibernateException {
View
47 spring-orm/src/main/java/org/springframework/orm/hibernate3/HibernateOperations.java
@@ -97,7 +97,7 @@
* call with a generic List type declared
*/
@Deprecated
- List<Object> executeFind(HibernateCallback<?> action) throws DataAccessException;
+ List<?> executeFind(HibernateCallback<?> action) throws DataAccessException;
//-------------------------------------------------------------------------
@@ -599,7 +599,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#createQuery
*/
- List<Object> find(String queryString) throws DataAccessException;
+ List<?> find(String queryString) throws DataAccessException;
/**
* Execute an HQL query, binding one value to a "?" parameter in the
@@ -610,7 +610,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#createQuery
*/
- List<Object> find(String queryString, Object value) throws DataAccessException;
+ List<?> find(String queryString, Object value) throws DataAccessException;
/**
* Execute an HQL query, binding a number of values to "?" parameters
@@ -621,7 +621,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#createQuery
*/
- List<Object> find(String queryString, Object... values) throws DataAccessException;
+ List<?> find(String queryString, Object... values) throws DataAccessException;
/**
* Execute an HQL query, binding one value to a ":" named parameter
@@ -633,8 +633,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedParam(String queryString, String paramName, Object value)
- throws DataAccessException;
+ List<?> findByNamedParam(String queryString, String paramName, Object value) throws DataAccessException;
/**
* Execute an HQL query, binding a number of values to ":" named
@@ -646,8 +645,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedParam(String queryString, String[] paramNames, Object[] values)
- throws DataAccessException;
+ List<?> findByNamedParam(String queryString, String[] paramNames, Object[] values) throws DataAccessException;
/**
* Execute an HQL query, binding the properties of the given bean to
@@ -659,7 +657,7 @@
* @see org.hibernate.Query#setProperties
* @see org.hibernate.Session#createQuery
*/
- List<Object> findByValueBean(String queryString, Object valueBean) throws DataAccessException;
+ List<?> findByValueBean(String queryString, Object valueBean) throws DataAccessException;
//-------------------------------------------------------------------------
@@ -674,7 +672,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQuery(String queryName) throws DataAccessException;
+ List<?> findByNamedQuery(String queryName) throws DataAccessException;
/**
* Execute a named query, binding one value to a "?" parameter in
@@ -686,7 +684,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQuery(String queryName, Object value) throws DataAccessException;
+ List<?> findByNamedQuery(String queryName, Object value) throws DataAccessException;
/**
* Execute a named query binding a number of values to "?" parameters
@@ -698,7 +696,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQuery(String queryName, Object... values) throws DataAccessException;
+ List<?> findByNamedQuery(String queryName, Object... values) throws DataAccessException;
/**
* Execute a named query, binding one value to a ":" named parameter
@@ -711,7 +709,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
+ List<?> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
throws DataAccessException;
/**
@@ -725,7 +723,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
+ List<?> findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
throws DataAccessException;
/**
@@ -739,8 +737,7 @@
* @see org.hibernate.Query#setProperties
* @see org.hibernate.Session#getNamedQuery(String)
*/
- List<Object> findByNamedQueryAndValueBean(String queryName, Object valueBean)
- throws DataAccessException;
+ List<?> findByNamedQueryAndValueBean(String queryName, Object valueBean) throws DataAccessException;
//-------------------------------------------------------------------------
@@ -756,7 +753,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.criterion.DetachedCriteria#getExecutableCriteria(org.hibernate.Session)
*/
- List<Object> findByCriteria(DetachedCriteria criteria) throws DataAccessException;
+ List<?> findByCriteria(DetachedCriteria criteria) throws DataAccessException;
/**
* Execute a query based on the given Hibernate criteria object.
@@ -773,7 +770,7 @@
* @see org.hibernate.Criteria#setFirstResult(int)
* @see org.hibernate.Criteria#setMaxResults(int)
*/
- List<Object> findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults) throws DataAccessException;
+ List<?> findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults) throws DataAccessException;
/**
* Execute a query based on the given example entity object.
@@ -783,7 +780,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.criterion.Example#create(Object)
*/
- List<Object> findByExample(Object exampleEntity) throws DataAccessException;
+ <T> List<T> findByExample(T exampleEntity) throws DataAccessException;
/**
* Execute a query based on the given example entity object.
@@ -794,7 +791,7 @@
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.criterion.Example#create(Object)
*/
- List<Object> findByExample(String entityName, Object exampleEntity) throws DataAccessException;
+ <T> List<T> findByExample(String entityName, T exampleEntity) throws DataAccessException;
/**
* Execute a query based on a given example entity object.
@@ -810,7 +807,7 @@
* @see org.hibernate.Criteria#setFirstResult(int)
* @see org.hibernate.Criteria#setMaxResults(int)
*/
- List<Object> findByExample(Object exampleEntity, int firstResult, int maxResults) throws DataAccessException;
+ <T> List<T> findByExample(T exampleEntity, int firstResult, int maxResults) throws DataAccessException;
/**
* Execute a query based on a given example entity object.
@@ -827,7 +824,7 @@
* @see org.hibernate.Criteria#setFirstResult(int)
* @see org.hibernate.Criteria#setMaxResults(int)
*/
- List<Object> findByExample(String entityName, Object exampleEntity, int firstResult, int maxResults)
+ <T> List<T> findByExample(String entityName, T exampleEntity, int firstResult, int maxResults)
throws DataAccessException;
@@ -845,7 +842,7 @@
* @see org.hibernate.Session#createQuery
* @see org.hibernate.Query#iterate
*/
- Iterator<Object> iterate(String queryString) throws DataAccessException;
+ Iterator<?> iterate(String queryString) throws DataAccessException;
/**
* Execute a query for persistent instances, binding one value
@@ -859,7 +856,7 @@
* @see org.hibernate.Session#createQuery
* @see org.hibernate.Query#iterate
*/
- Iterator<Object> iterate(String queryString, Object value) throws DataAccessException;
+ Iterator<?> iterate(String queryString, Object value) throws DataAccessException;
/**
* Execute a query for persistent instances, binding a number of
@@ -873,7 +870,7 @@
* @see org.hibernate.Session#createQuery
* @see org.hibernate.Query#iterate
*/
- Iterator<Object> iterate(String queryString, Object... values) throws DataAccessException;
+ Iterator<?> iterate(String queryString, Object... values) throws DataAccessException;
/**
* Immediately close an {@link Iterator} created by any of the various
View
86 spring-orm/src/main/java/org/springframework/orm/hibernate3/HibernateTemplate.java
@@ -344,13 +344,13 @@ public int getMaxResults() {
@Override
@Deprecated
@SuppressWarnings("unchecked")
- public List<Object> executeFind(HibernateCallback<?> action) throws DataAccessException {
+ public List<?> executeFind(HibernateCallback<?> action) throws DataAccessException {
Object result = doExecute(action, false, false);
if (result != null && !(result instanceof List)) {
throw new InvalidDataAccessApiUsageException(
"Result object returned from HibernateCallback isn't a List: [" + result + "]");
}
- return (List<Object>) result;
+ return (List<?>) result;
}
/**
@@ -563,7 +563,7 @@ public Object doInHibernate(Session session) throws HibernateException {
return executeWithNativeSession(new HibernateCallback<T>() {
@Override
- @SuppressWarnings({ "unchecked" })
+ @SuppressWarnings("unchecked")
public T doInHibernate(Session session) throws HibernateException {
if (lockMode != null) {
return (T) session.load(entityClass, id, lockMode);
@@ -961,21 +961,21 @@ public Object doInHibernate(Session session) {
//-------------------------------------------------------------------------
@Override
- public List<Object> find(String queryString) throws DataAccessException {
+ public List<?> find(String queryString) throws DataAccessException {
return find(queryString, (Object[]) null);
}
@Override
- public List<Object> find(String queryString, Object value) throws DataAccessException {
+ public List<?> find(String queryString, Object value) throws DataAccessException {
return find(queryString, new Object[] {value});
}
@Override
- public List<Object> find(final String queryString, final Object... values) throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ public List<?> find(final String queryString, final Object... values) throws DataAccessException {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
prepareQuery(queryObject);
if (values != null) {
@@ -989,23 +989,23 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByNamedParam(String queryString, String paramName, Object value)
+ public List<?> findByNamedParam(String queryString, String paramName, Object value)
throws DataAccessException {
return findByNamedParam(queryString, new String[] {paramName}, new Object[] {value});
}
@Override
- public List<Object> findByNamedParam(final String queryString, final String[] paramNames, final Object[] values)
+ public List<?> findByNamedParam(final String queryString, final String[] paramNames, final Object[] values)
throws DataAccessException {
if (paramNames.length != values.length) {
throw new IllegalArgumentException("Length of paramNames array must match length of values array");
}
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
prepareQuery(queryObject);
if (values != null) {
@@ -1019,13 +1019,13 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByValueBean(final String queryString, final Object valueBean)
+ public List<?> findByValueBean(final String queryString, final Object valueBean)
throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
prepareQuery(queryObject);
queryObject.setProperties(valueBean);
@@ -1040,21 +1040,21 @@ public Object doInHibernate(Session session) {
//-------------------------------------------------------------------------
@Override
- public List<Object> findByNamedQuery(String queryName) throws DataAccessException {
+ public List<?> findByNamedQuery(String queryName) throws DataAccessException {
return findByNamedQuery(queryName, (Object[]) null);
}
@Override
- public List<Object> findByNamedQuery(String queryName, Object value) throws DataAccessException {
+ public List<?> findByNamedQuery(String queryName, Object value) throws DataAccessException {
return findByNamedQuery(queryName, new Object[] {value});
}
@Override
- public List<Object> findByNamedQuery(final String queryName, final Object... values) throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ public List<?> findByNamedQuery(final String queryName, final Object... values) throws DataAccessException {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.getNamedQuery(queryName);
prepareQuery(queryObject);
if (values != null) {
@@ -1068,24 +1068,24 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
+ public List<?> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
throws DataAccessException {
return findByNamedQueryAndNamedParam(queryName, new String[] {paramName}, new Object[] {value});
}
@Override
- public List<Object> findByNamedQueryAndNamedParam(
+ public List<?> findByNamedQueryAndNamedParam(
final String queryName, final String[] paramNames, final Object[] values)
throws DataAccessException {
if (values != null && (paramNames == null || paramNames.length != values.length)) {
throw new IllegalArgumentException("Length of paramNames array must match length of values array");
}
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.getNamedQuery(queryName);
prepareQuery(queryObject);
if (values != null) {
@@ -1099,13 +1099,13 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByNamedQueryAndValueBean(final String queryName, final Object valueBean)
+ public List<?> findByNamedQueryAndValueBean(final String queryName, final Object valueBean)
throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.getNamedQuery(queryName);
prepareQuery(queryObject);
queryObject.setProperties(valueBean);
@@ -1120,19 +1120,19 @@ public Object doInHibernate(Session session) {
//-------------------------------------------------------------------------
@Override
- public List<Object> findByCriteria(DetachedCriteria criteria) throws DataAccessException {
+ public List<?> findByCriteria(DetachedCriteria criteria) throws DataAccessException {
return findByCriteria(criteria, -1, -1);
}
@Override
- public List<Object> findByCriteria(final DetachedCriteria criteria, final int firstResult, final int maxResults)
+ public List<?> findByCriteria(final DetachedCriteria criteria, final int firstResult, final int maxResults)
throws DataAccessException {
Assert.notNull(criteria, "DetachedCriteria must not be null");
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<?>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<?> doInHibernate(Session session) throws HibernateException {
Criteria executableCriteria = criteria.getExecutableCriteria(session);
prepareCriteria(executableCriteria);
if (firstResult >= 0) {
@@ -1147,30 +1147,30 @@ public Object doInHibernate(Session session) {
}
@Override
- public List<Object> findByExample(Object exampleEntity) throws DataAccessException {
+ public <T> List<T> findByExample(T exampleEntity) throws DataAccessException {
return findByExample(null, exampleEntity, -1, -1);
}
@Override
- public List<Object> findByExample(String entityName, Object exampleEntity) throws DataAccessException {
+ public <T> List<T> findByExample(String entityName, T exampleEntity) throws DataAccessException {
return findByExample(entityName, exampleEntity, -1, -1);
}
@Override
- public List<Object> findByExample(Object exampleEntity, int firstResult, int maxResults) throws DataAccessException {
+ public <T> List<T> findByExample(T exampleEntity, int firstResult, int maxResults) throws DataAccessException {
return findByExample(null, exampleEntity, firstResult, maxResults);
}
@Override
- public List<Object> findByExample(
- final String entityName, final Object exampleEntity, final int firstResult, final int maxResults)
+ public <T> List<T> findByExample(
+ final String entityName, final T exampleEntity, final int firstResult, final int maxResults)
throws DataAccessException {
Assert.notNull(exampleEntity, "Example entity must not be null");
- return executeWithNativeSession(new HibernateCallback<List<Object>>() {
+ return executeWithNativeSession(new HibernateCallback<List<T>>() {
@Override
@SuppressWarnings("unchecked")
- public List<Object> doInHibernate(Session session) throws HibernateException {
+ public List<T> doInHibernate(Session session) throws HibernateException {
Criteria executableCriteria = (entityName != null ?
session.createCriteria(entityName) : session.createCriteria(exampleEntity.getClass()));
executableCriteria.add(Example.create(exampleEntity));
@@ -1192,21 +1192,21 @@ public Object doInHibernate(Session session) {
//-------------------------------------------------------------------------
@Override
- public Iterator<Object> iterate(String queryString) throws DataAccessException {
+ public Iterator<?> iterate(String queryString) throws DataAccessException {
return iterate(queryString, (Object[]) null);
}
@Override
- public Iterator<Object> iterate(String queryString, Object value) throws DataAccessException {
+ public Iterator<?> iterate(String queryString, Object value) throws DataAccessException {
return iterate(queryString, new Object[] {value});
}
@Override
- public Iterator<Object> iterate(final String queryString, final Object... values) throws DataAccessException {
- return executeWithNativeSession(new HibernateCallback<Iterator<Object>>() {
+ public Iterator<?> iterate(final String queryString, final Object... values) throws DataAccessException {
+ return executeWithNativeSession(new HibernateCallback<Iterator<?>>() {
@Override
@SuppressWarnings("unchecked")
- public Iterator<Object> doInHibernate(Session session) throws HibernateException {
+ public Iterator<?> doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
prepareQuery(queryObject);
if (values != null) {

0 comments on commit 99f9dce

Please sign in to comment.