Fix remaining compiler warnings
Fix remaining Java compiler warnings, mainly around missing generics or deprecated code. Also add the `-Werror` compiler option to ensure that any future warnings will fail the build. Issue: SPR-11064
This commit is contained in:
@@ -49,7 +49,7 @@ public class ObjectOptimisticLockingFailureException extends OptimisticLockingFa
|
||||
* @param persistentClass the persistent class
|
||||
* @param identifier the ID of the object for which the locking failed
|
||||
*/
|
||||
public ObjectOptimisticLockingFailureException(Class persistentClass, Object identifier) {
|
||||
public ObjectOptimisticLockingFailureException(Class<?> persistentClass, Object identifier) {
|
||||
this(persistentClass, identifier, null);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ObjectOptimisticLockingFailureException extends OptimisticLockingFa
|
||||
* @param cause the source exception
|
||||
*/
|
||||
public ObjectOptimisticLockingFailureException(
|
||||
Class persistentClass, Object identifier, Throwable cause) {
|
||||
Class<?> persistentClass, Object identifier, Throwable cause) {
|
||||
|
||||
this(persistentClass, identifier,
|
||||
"Object of class [" + persistentClass.getName() + "] with identifier [" + identifier +
|
||||
@@ -77,7 +77,7 @@ public class ObjectOptimisticLockingFailureException extends OptimisticLockingFa
|
||||
* @param cause the source exception
|
||||
*/
|
||||
public ObjectOptimisticLockingFailureException(
|
||||
Class persistentClass, Object identifier, String msg, Throwable cause) {
|
||||
Class<?> persistentClass, Object identifier, String msg, Throwable cause) {
|
||||
|
||||
super(msg, cause);
|
||||
this.persistentClass = persistentClass;
|
||||
@@ -130,8 +130,8 @@ public class ObjectOptimisticLockingFailureException extends OptimisticLockingFa
|
||||
* Return the persistent class of the object for which the locking failed.
|
||||
* If no Class was specified, this method returns null.
|
||||
*/
|
||||
public Class getPersistentClass() {
|
||||
return (this.persistentClass instanceof Class ? (Class) this.persistentClass : null);
|
||||
public Class<?> getPersistentClass() {
|
||||
return (this.persistentClass instanceof Class ? (Class<?>) this.persistentClass : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ public class ObjectOptimisticLockingFailureException extends OptimisticLockingFa
|
||||
*/
|
||||
public String getPersistentClassName() {
|
||||
if (this.persistentClass instanceof Class) {
|
||||
return ((Class) this.persistentClass).getName();
|
||||
return ((Class<?>) this.persistentClass).getName();
|
||||
}
|
||||
return (this.persistentClass != null ? this.persistentClass.toString() : null);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ObjectRetrievalFailureException extends DataRetrievalFailureExcepti
|
||||
* @param persistentClass the persistent class
|
||||
* @param identifier the ID of the object that should have been retrieved
|
||||
*/
|
||||
public ObjectRetrievalFailureException(Class persistentClass, Object identifier) {
|
||||
public ObjectRetrievalFailureException(Class<?> persistentClass, Object identifier) {
|
||||
this(persistentClass, identifier,
|
||||
"Object of class [" + persistentClass.getName() + "] with identifier [" + identifier + "]: not found",
|
||||
null);
|
||||
@@ -64,7 +64,7 @@ public class ObjectRetrievalFailureException extends DataRetrievalFailureExcepti
|
||||
* @param cause the source exception
|
||||
*/
|
||||
public ObjectRetrievalFailureException(
|
||||
Class persistentClass, Object identifier, String msg, Throwable cause) {
|
||||
Class<?> persistentClass, Object identifier, String msg, Throwable cause) {
|
||||
|
||||
super(msg, cause);
|
||||
this.persistentClass = persistentClass;
|
||||
@@ -104,8 +104,8 @@ public class ObjectRetrievalFailureException extends DataRetrievalFailureExcepti
|
||||
* Return the persistent class of the object that was not found.
|
||||
* If no Class was specified, this method returns null.
|
||||
*/
|
||||
public Class getPersistentClass() {
|
||||
return (this.persistentClass instanceof Class ? (Class) this.persistentClass : null);
|
||||
public Class<?> getPersistentClass() {
|
||||
return (this.persistentClass instanceof Class ? (Class<?>) this.persistentClass : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ public class ObjectRetrievalFailureException extends DataRetrievalFailureExcepti
|
||||
*/
|
||||
public String getPersistentClassName() {
|
||||
if (this.persistentClass instanceof Class) {
|
||||
return ((Class) this.persistentClass).getName();
|
||||
return ((Class<?>) this.persistentClass).getName();
|
||||
}
|
||||
return (this.persistentClass != null ? this.persistentClass.toString() : null);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public interface HibernateOperations {
|
||||
* @return a List result returned by the action, or {@code null}
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
*/
|
||||
List executeFind(HibernateCallback<?> action) throws DataAccessException;
|
||||
List<Object> executeFind(HibernateCallback<?> action) throws DataAccessException;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -245,7 +245,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException if there is a Hibernate error
|
||||
* @see org.hibernate.Session#createCriteria
|
||||
*/
|
||||
<T>List<T> loadAll(Class<T> entityClass) throws DataAccessException;
|
||||
<T> List<T> loadAll(Class<T> entityClass) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Load the persistent instance with the given identifier
|
||||
@@ -567,7 +567,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#delete(Object)
|
||||
*/
|
||||
void deleteAll(Collection entities) throws DataAccessException;
|
||||
void deleteAll(Collection<?> entities) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Flush all pending saves, updates and deletes to the database.
|
||||
@@ -600,7 +600,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#createQuery
|
||||
*/
|
||||
List find(String queryString) throws DataAccessException;
|
||||
List<?> find(String queryString) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute an HQL query, binding one value to a "?" parameter in the
|
||||
@@ -611,7 +611,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#createQuery
|
||||
*/
|
||||
List find(String queryString, Object value) throws DataAccessException;
|
||||
List<Object> find(String queryString, Object value) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute an HQL query, binding a number of values to "?" parameters
|
||||
@@ -622,7 +622,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#createQuery
|
||||
*/
|
||||
List find(String queryString, Object... values) throws DataAccessException;
|
||||
List<Object> find(String queryString, Object... values) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute an HQL query, binding one value to a ":" named parameter
|
||||
@@ -634,7 +634,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#getNamedQuery(String)
|
||||
*/
|
||||
List findByNamedParam(String queryString, String paramName, Object value)
|
||||
List<Object> findByNamedParam(String queryString, String paramName, Object value)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
@@ -647,7 +647,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#getNamedQuery(String)
|
||||
*/
|
||||
List findByNamedParam(String queryString, String[] paramNames, Object[] values)
|
||||
List<Object> findByNamedParam(String queryString, String[] paramNames, Object[] values)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
@@ -660,7 +660,7 @@ public interface HibernateOperations {
|
||||
* @see org.hibernate.Query#setProperties
|
||||
* @see org.hibernate.Session#createQuery
|
||||
*/
|
||||
List findByValueBean(String queryString, Object valueBean) throws DataAccessException;
|
||||
List<Object> findByValueBean(String queryString, Object valueBean) throws DataAccessException;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -675,7 +675,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#getNamedQuery(String)
|
||||
*/
|
||||
List findByNamedQuery(String queryName) throws DataAccessException;
|
||||
List<Object> findByNamedQuery(String queryName) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a named query, binding one value to a "?" parameter in
|
||||
@@ -687,7 +687,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#getNamedQuery(String)
|
||||
*/
|
||||
List findByNamedQuery(String queryName, Object value) throws DataAccessException;
|
||||
List<Object> findByNamedQuery(String queryName, Object value) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a named query binding a number of values to "?" parameters
|
||||
@@ -699,7 +699,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#getNamedQuery(String)
|
||||
*/
|
||||
List findByNamedQuery(String queryName, Object... values) throws DataAccessException;
|
||||
List<Object> findByNamedQuery(String queryName, Object... values) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a named query, binding one value to a ":" named parameter
|
||||
@@ -712,7 +712,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#getNamedQuery(String)
|
||||
*/
|
||||
List findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
|
||||
List<Object> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
@@ -726,7 +726,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.Session#getNamedQuery(String)
|
||||
*/
|
||||
List findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
|
||||
List<Object> findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
@@ -740,7 +740,7 @@ public interface HibernateOperations {
|
||||
* @see org.hibernate.Query#setProperties
|
||||
* @see org.hibernate.Session#getNamedQuery(String)
|
||||
*/
|
||||
List findByNamedQueryAndValueBean(String queryName, Object valueBean)
|
||||
List<Object> findByNamedQueryAndValueBean(String queryName, Object valueBean)
|
||||
throws DataAccessException;
|
||||
|
||||
|
||||
@@ -757,7 +757,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.criterion.DetachedCriteria#getExecutableCriteria(org.hibernate.Session)
|
||||
*/
|
||||
List findByCriteria(DetachedCriteria criteria) throws DataAccessException;
|
||||
List<Object> findByCriteria(DetachedCriteria criteria) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a query based on the given Hibernate criteria object.
|
||||
@@ -774,7 +774,7 @@ public interface HibernateOperations {
|
||||
* @see org.hibernate.Criteria#setFirstResult(int)
|
||||
* @see org.hibernate.Criteria#setMaxResults(int)
|
||||
*/
|
||||
List findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults) throws DataAccessException;
|
||||
List<Object> findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a query based on the given example entity object.
|
||||
@@ -784,7 +784,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.criterion.Example#create(Object)
|
||||
*/
|
||||
List findByExample(Object exampleEntity) throws DataAccessException;
|
||||
List<Object> findByExample(Object exampleEntity) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a query based on the given example entity object.
|
||||
@@ -795,7 +795,7 @@ public interface HibernateOperations {
|
||||
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
|
||||
* @see org.hibernate.criterion.Example#create(Object)
|
||||
*/
|
||||
List findByExample(String entityName, Object exampleEntity) throws DataAccessException;
|
||||
List<Object> findByExample(String entityName, Object exampleEntity) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a query based on a given example entity object.
|
||||
@@ -811,7 +811,7 @@ public interface HibernateOperations {
|
||||
* @see org.hibernate.Criteria#setFirstResult(int)
|
||||
* @see org.hibernate.Criteria#setMaxResults(int)
|
||||
*/
|
||||
List findByExample(Object exampleEntity, int firstResult, int maxResults) throws DataAccessException;
|
||||
List<Object> findByExample(Object exampleEntity, int firstResult, int maxResults) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a query based on a given example entity object.
|
||||
@@ -828,7 +828,7 @@ public interface HibernateOperations {
|
||||
* @see org.hibernate.Criteria#setFirstResult(int)
|
||||
* @see org.hibernate.Criteria#setMaxResults(int)
|
||||
*/
|
||||
List findByExample(String entityName, Object exampleEntity, int firstResult, int maxResults)
|
||||
List<Object> findByExample(String entityName, Object exampleEntity, int firstResult, int maxResults)
|
||||
throws DataAccessException;
|
||||
|
||||
|
||||
@@ -846,7 +846,7 @@ public interface HibernateOperations {
|
||||
* @see org.hibernate.Session#createQuery
|
||||
* @see org.hibernate.Query#iterate
|
||||
*/
|
||||
Iterator iterate(String queryString) throws DataAccessException;
|
||||
Iterator<Object> iterate(String queryString) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a query for persistent instances, binding one value
|
||||
@@ -860,7 +860,7 @@ public interface HibernateOperations {
|
||||
* @see org.hibernate.Session#createQuery
|
||||
* @see org.hibernate.Query#iterate
|
||||
*/
|
||||
Iterator iterate(String queryString, Object value) throws DataAccessException;
|
||||
Iterator<Object> iterate(String queryString, Object value) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a query for persistent instances, binding a number of
|
||||
@@ -874,7 +874,7 @@ public interface HibernateOperations {
|
||||
* @see org.hibernate.Session#createQuery
|
||||
* @see org.hibernate.Query#iterate
|
||||
*/
|
||||
Iterator iterate(String queryString, Object... values) throws DataAccessException;
|
||||
Iterator<Object> iterate(String queryString, Object... values) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Immediately close an {@link Iterator} created by any of the various
|
||||
@@ -884,7 +884,7 @@ public interface HibernateOperations {
|
||||
* @throws DataAccessException if the {@code Iterator} could not be closed
|
||||
* @see org.hibernate.Hibernate#close
|
||||
*/
|
||||
void closeIterator(Iterator it) throws DataAccessException;
|
||||
void closeIterator(Iterator<?> it) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Update/delete all objects according to the given query.
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.hibernate.criterion.DetachedCriteria;
|
||||
import org.hibernate.criterion.Example;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.event.EventSource;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
@@ -105,6 +104,7 @@ import org.springframework.util.Assert;
|
||||
* @see org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
|
||||
* @see org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HibernateTemplate extends HibernateAccessor implements HibernateOperations {
|
||||
|
||||
private boolean allowCreate = true;
|
||||
@@ -341,13 +341,14 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List executeFind(HibernateCallback<?> action) throws DataAccessException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> 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) result;
|
||||
return (List<Object>) result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,17 +483,17 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
* @see #prepareCriteria
|
||||
*/
|
||||
protected Session createSessionProxy(Session session) {
|
||||
Class[] sessionIfcs = null;
|
||||
Class mainIfc = (session instanceof org.hibernate.classic.Session ?
|
||||
Class<?>[] sessionIfcs = null;
|
||||
Class<?> mainIfc = (session instanceof org.hibernate.classic.Session ?
|
||||
org.hibernate.classic.Session.class : Session.class);
|
||||
if (session instanceof EventSource) {
|
||||
sessionIfcs = new Class[] {mainIfc, EventSource.class};
|
||||
sessionIfcs = new Class<?>[] {mainIfc, EventSource.class};
|
||||
}
|
||||
else if (session instanceof SessionImplementor) {
|
||||
sessionIfcs = new Class[] {mainIfc, SessionImplementor.class};
|
||||
sessionIfcs = new Class<?>[] {mainIfc, SessionImplementor.class};
|
||||
}
|
||||
else {
|
||||
sessionIfcs = new Class[] {mainIfc};
|
||||
sessionIfcs = new Class<?>[] {mainIfc};
|
||||
}
|
||||
return (Session) Proxy.newProxyInstance(
|
||||
session.getClass().getClassLoader(), sessionIfcs,
|
||||
@@ -515,7 +516,7 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
|
||||
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, lockMode);
|
||||
@@ -560,7 +561,7 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
|
||||
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);
|
||||
@@ -917,7 +918,7 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(final Collection entities) throws DataAccessException {
|
||||
public void deleteAll(final Collection<?> entities) throws DataAccessException {
|
||||
executeWithNativeSession(new HibernateCallback<Object>() {
|
||||
@Override
|
||||
public Object doInHibernate(Session session) throws HibernateException {
|
||||
@@ -958,20 +959,21 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public List find(String queryString) throws DataAccessException {
|
||||
public List<Object> find(String queryString) throws DataAccessException {
|
||||
return find(queryString, (Object[]) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List find(String queryString, Object value) throws DataAccessException {
|
||||
public List<Object> find(String queryString, Object value) throws DataAccessException {
|
||||
return find(queryString, new Object[] {value});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List find(final String queryString, final Object... values) throws DataAccessException {
|
||||
return executeWithNativeSession(new HibernateCallback<List>() {
|
||||
public List<Object> find(final String queryString, final Object... values) throws DataAccessException {
|
||||
return executeWithNativeSession(new HibernateCallback<List<Object>>() {
|
||||
@Override
|
||||
public List doInHibernate(Session session) throws HibernateException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> doInHibernate(Session session) throws HibernateException {
|
||||
Query queryObject = session.createQuery(queryString);
|
||||
prepareQuery(queryObject);
|
||||
if (values != null) {
|
||||
@@ -985,22 +987,23 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByNamedParam(String queryString, String paramName, Object value)
|
||||
public List<Object> findByNamedParam(String queryString, String paramName, Object value)
|
||||
throws DataAccessException {
|
||||
|
||||
return findByNamedParam(queryString, new String[] {paramName}, new Object[] {value});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByNamedParam(final String queryString, final String[] paramNames, final Object[] values)
|
||||
public List<Object> 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>() {
|
||||
return executeWithNativeSession(new HibernateCallback<List<Object>>() {
|
||||
@Override
|
||||
public List doInHibernate(Session session) throws HibernateException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> doInHibernate(Session session) throws HibernateException {
|
||||
Query queryObject = session.createQuery(queryString);
|
||||
prepareQuery(queryObject);
|
||||
if (values != null) {
|
||||
@@ -1014,12 +1017,13 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByValueBean(final String queryString, final Object valueBean)
|
||||
public List<Object> findByValueBean(final String queryString, final Object valueBean)
|
||||
throws DataAccessException {
|
||||
|
||||
return executeWithNativeSession(new HibernateCallback<List>() {
|
||||
return executeWithNativeSession(new HibernateCallback<List<Object>>() {
|
||||
@Override
|
||||
public List doInHibernate(Session session) throws HibernateException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> doInHibernate(Session session) throws HibernateException {
|
||||
Query queryObject = session.createQuery(queryString);
|
||||
prepareQuery(queryObject);
|
||||
queryObject.setProperties(valueBean);
|
||||
@@ -1034,20 +1038,21 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public List findByNamedQuery(String queryName) throws DataAccessException {
|
||||
public List<Object> findByNamedQuery(String queryName) throws DataAccessException {
|
||||
return findByNamedQuery(queryName, (Object[]) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByNamedQuery(String queryName, Object value) throws DataAccessException {
|
||||
public List<Object> findByNamedQuery(String queryName, Object value) throws DataAccessException {
|
||||
return findByNamedQuery(queryName, new Object[] {value});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByNamedQuery(final String queryName, final Object... values) throws DataAccessException {
|
||||
return executeWithNativeSession(new HibernateCallback<List>() {
|
||||
public List<Object> findByNamedQuery(final String queryName, final Object... values) throws DataAccessException {
|
||||
return executeWithNativeSession(new HibernateCallback<List<Object>>() {
|
||||
@Override
|
||||
public List doInHibernate(Session session) throws HibernateException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> doInHibernate(Session session) throws HibernateException {
|
||||
Query queryObject = session.getNamedQuery(queryName);
|
||||
prepareQuery(queryObject);
|
||||
if (values != null) {
|
||||
@@ -1061,23 +1066,24 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
|
||||
public List<Object> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
|
||||
throws DataAccessException {
|
||||
|
||||
return findByNamedQueryAndNamedParam(queryName, new String[] {paramName}, new Object[] {value});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByNamedQueryAndNamedParam(
|
||||
public List<Object> findByNamedQueryAndNamedParam(
|
||||
final String queryName, final String[] paramNames, final Object[] values)
|
||||
throws DataAccessException {
|
||||
|
||||
if (paramNames != null && values != null && paramNames.length != values.length) {
|
||||
throw new IllegalArgumentException("Length of paramNames array must match length of values array");
|
||||
}
|
||||
return executeWithNativeSession(new HibernateCallback<List>() {
|
||||
return executeWithNativeSession(new HibernateCallback<List<Object>>() {
|
||||
@Override
|
||||
public List doInHibernate(Session session) throws HibernateException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> doInHibernate(Session session) throws HibernateException {
|
||||
Query queryObject = session.getNamedQuery(queryName);
|
||||
prepareQuery(queryObject);
|
||||
if (values != null) {
|
||||
@@ -1091,12 +1097,13 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByNamedQueryAndValueBean(final String queryName, final Object valueBean)
|
||||
public List<Object> findByNamedQueryAndValueBean(final String queryName, final Object valueBean)
|
||||
throws DataAccessException {
|
||||
|
||||
return executeWithNativeSession(new HibernateCallback<List>() {
|
||||
return executeWithNativeSession(new HibernateCallback<List<Object>>() {
|
||||
@Override
|
||||
public List doInHibernate(Session session) throws HibernateException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> doInHibernate(Session session) throws HibernateException {
|
||||
Query queryObject = session.getNamedQuery(queryName);
|
||||
prepareQuery(queryObject);
|
||||
queryObject.setProperties(valueBean);
|
||||
@@ -1111,18 +1118,19 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public List findByCriteria(DetachedCriteria criteria) throws DataAccessException {
|
||||
public List<Object> findByCriteria(DetachedCriteria criteria) throws DataAccessException {
|
||||
return findByCriteria(criteria, -1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByCriteria(final DetachedCriteria criteria, final int firstResult, final int maxResults)
|
||||
public List<Object> 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>() {
|
||||
return executeWithNativeSession(new HibernateCallback<List<Object>>() {
|
||||
@Override
|
||||
public List doInHibernate(Session session) throws HibernateException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> doInHibernate(Session session) throws HibernateException {
|
||||
Criteria executableCriteria = criteria.getExecutableCriteria(session);
|
||||
prepareCriteria(executableCriteria);
|
||||
if (firstResult >= 0) {
|
||||
@@ -1137,29 +1145,30 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByExample(Object exampleEntity) throws DataAccessException {
|
||||
public List<Object> findByExample(Object exampleEntity) throws DataAccessException {
|
||||
return findByExample(null, exampleEntity, -1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByExample(String entityName, Object exampleEntity) throws DataAccessException {
|
||||
public List<Object> findByExample(String entityName, Object exampleEntity) throws DataAccessException {
|
||||
return findByExample(entityName, exampleEntity, -1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByExample(Object exampleEntity, int firstResult, int maxResults) throws DataAccessException {
|
||||
public List<Object> findByExample(Object exampleEntity, int firstResult, int maxResults) throws DataAccessException {
|
||||
return findByExample(null, exampleEntity, firstResult, maxResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findByExample(
|
||||
public List<Object> findByExample(
|
||||
final String entityName, final Object exampleEntity, final int firstResult, final int maxResults)
|
||||
throws DataAccessException {
|
||||
|
||||
Assert.notNull(exampleEntity, "Example entity must not be null");
|
||||
return executeWithNativeSession(new HibernateCallback<List>() {
|
||||
return executeWithNativeSession(new HibernateCallback<List<Object>>() {
|
||||
@Override
|
||||
public List doInHibernate(Session session) throws HibernateException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> doInHibernate(Session session) throws HibernateException {
|
||||
Criteria executableCriteria = (entityName != null ?
|
||||
session.createCriteria(entityName) : session.createCriteria(exampleEntity.getClass()));
|
||||
executableCriteria.add(Example.create(exampleEntity));
|
||||
@@ -1181,20 +1190,21 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Iterator iterate(String queryString) throws DataAccessException {
|
||||
public Iterator<Object> iterate(String queryString) throws DataAccessException {
|
||||
return iterate(queryString, (Object[]) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator iterate(String queryString, Object value) throws DataAccessException {
|
||||
public Iterator<Object> iterate(String queryString, Object value) throws DataAccessException {
|
||||
return iterate(queryString, new Object[] {value});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator iterate(final String queryString, final Object... values) throws DataAccessException {
|
||||
return executeWithNativeSession(new HibernateCallback<Iterator>() {
|
||||
public Iterator<Object> iterate(final String queryString, final Object... values) throws DataAccessException {
|
||||
return executeWithNativeSession(new HibernateCallback<Iterator<Object>>() {
|
||||
@Override
|
||||
public Iterator doInHibernate(Session session) throws HibernateException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterator<Object> doInHibernate(Session session) throws HibernateException {
|
||||
Query queryObject = session.createQuery(queryString);
|
||||
prepareQuery(queryObject);
|
||||
if (values != null) {
|
||||
@@ -1208,7 +1218,7 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeIterator(Iterator it) throws DataAccessException {
|
||||
public void closeIterator(Iterator<?> it) throws DataAccessException {
|
||||
try {
|
||||
Hibernate.close(it);
|
||||
}
|
||||
@@ -1329,7 +1339,7 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
|
||||
throws HibernateException {
|
||||
|
||||
if (value instanceof Collection) {
|
||||
queryObject.setParameterList(paramName, (Collection) value);
|
||||
queryObject.setParameterList(paramName, (Collection<?>) value);
|
||||
}
|
||||
else if (value instanceof Object[]) {
|
||||
queryObject.setParameterList(paramName, (Object[]) value);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.orm.hibernate3;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
@@ -29,7 +30,6 @@ import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.exception.GenericJDBCException;
|
||||
import org.hibernate.impl.SessionImpl;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
@@ -475,6 +475,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition) {
|
||||
HibernateTransactionObject txObject = (HibernateTransactionObject) transaction;
|
||||
|
||||
@@ -706,6 +707,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void doCleanupAfterCompletion(Object transaction) {
|
||||
HibernateTransactionObject txObject = (HibernateTransactionObject) transaction;
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.orm.hibernate3;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.cache.CacheDataDescription;
|
||||
@@ -29,8 +28,6 @@ import org.hibernate.cache.TimestampsRegion;
|
||||
import org.hibernate.cache.access.AccessType;
|
||||
import org.hibernate.cfg.Settings;
|
||||
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Proxy for a Hibernate RegionFactory, delegating to a Spring-managed
|
||||
* RegionFactory instance, determined by LocalSessionFactoryBean's
|
||||
|
||||
@@ -114,10 +114,6 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
|
||||
private static final ThreadLocal<Object> configTimeRegionFactoryHolder =
|
||||
new ThreadLocal<Object>();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final ThreadLocal<org.hibernate.cache.CacheProvider> configTimeCacheProviderHolder =
|
||||
new ThreadLocal<org.hibernate.cache.CacheProvider>();
|
||||
|
||||
private static final ThreadLocal<LobHandler> configTimeLobHandlerHolder =
|
||||
new ThreadLocal<LobHandler>();
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.Transaction;
|
||||
@@ -56,7 +57,6 @@ import org.hibernate.exception.DataException;
|
||||
import org.hibernate.exception.JDBCConnectionException;
|
||||
import org.hibernate.exception.LockAcquisitionException;
|
||||
import org.hibernate.exception.SQLGrammarException;
|
||||
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
import org.springframework.dao.CannotAcquireLockException;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -513,6 +513,7 @@ public abstract class SessionFactoryUtils {
|
||||
* @param entityInterceptor Hibernate entity interceptor, or {@code null} if none
|
||||
* @return the new Session
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Session getNewSession(SessionFactory sessionFactory, Interceptor entityInterceptor) {
|
||||
Assert.notNull(sessionFactory, "No SessionFactory specified");
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.orm.hibernate3.annotation;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
@@ -24,7 +25,6 @@ import javax.persistence.MappedSuperclass;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
@@ -81,7 +81,7 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
|
||||
private static final String PACKAGE_INFO_SUFFIX = ".package-info";
|
||||
|
||||
|
||||
private Class[] annotatedClasses;
|
||||
private Class<?>[] annotatedClasses;
|
||||
|
||||
private String[] annotatedPackages;
|
||||
|
||||
@@ -101,7 +101,7 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
|
||||
* class-level JDK 1.5+ annotation metadata.
|
||||
* @see org.hibernate.cfg.Configuration#addAnnotatedClass(Class)
|
||||
*/
|
||||
public void setAnnotatedClasses(Class[] annotatedClasses) {
|
||||
public void setAnnotatedClasses(Class<?>[] annotatedClasses) {
|
||||
this.annotatedClasses = annotatedClasses;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
|
||||
@Override
|
||||
protected void postProcessMappings(Configuration config) throws HibernateException {
|
||||
if (this.annotatedClasses != null) {
|
||||
for (Class annotatedClass : this.annotatedClasses) {
|
||||
for (Class<?> annotatedClass : this.annotatedClasses) {
|
||||
config.addAnnotatedClass(annotatedClass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,7 @@ public abstract class AbstractLobType implements UserType {
|
||||
* @see #nullSafeGetInternal
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public final Object nullSafeGet(ResultSet rs, String[] names, Object owner)
|
||||
throws HibernateException, SQLException {
|
||||
|
||||
@@ -171,6 +172,7 @@ public abstract class AbstractLobType implements UserType {
|
||||
* @see #nullSafeSetInternal
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public final void nullSafeSet(PreparedStatement st, Object value, int index)
|
||||
throws HibernateException, SQLException {
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class BlobByteArrayType extends AbstractLobType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class returnedClass() {
|
||||
public Class<?> returnedClass() {
|
||||
return byte[].class;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class BlobSerializableType extends AbstractLobType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class returnedClass() {
|
||||
public Class<?> returnedClass() {
|
||||
return Serializable.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class BlobStringType extends AbstractLobType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class returnedClass() {
|
||||
public Class<?> returnedClass() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ClobStringType extends AbstractLobType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class returnedClass() {
|
||||
public Class<?> returnedClass() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||
* @since 1.2
|
||||
* @see org.springframework.orm.hibernate3.LocalSessionFactoryBean#setEventListeners(java.util.Map)
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@SuppressWarnings({ "serial", "rawtypes", "deprecation" })
|
||||
public class IdTransferringMergeEventListener extends DefaultMergeEventListener {
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.orm.hibernate3.support;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -27,9 +25,9 @@ import org.springframework.orm.hibernate3.SessionHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.context.request.async.*;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
|
||||
/**
|
||||
* Spring web request interceptor that binds a Hibernate {@code Session} to the
|
||||
|
||||
@@ -268,7 +268,7 @@ public class LocalPersistenceManagerFactoryBean implements FactoryBean<Persisten
|
||||
* @return the PersistenceManagerFactory instance
|
||||
* @see javax.jdo.JDOHelper#getPersistenceManagerFactory(java.util.Map)
|
||||
*/
|
||||
protected PersistenceManagerFactory newPersistenceManagerFactory(Map props) {
|
||||
protected PersistenceManagerFactory newPersistenceManagerFactory(Map<?, ?> props) {
|
||||
return JDOHelper.getPersistenceManagerFactory(props, this.beanClassLoader);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class TransactionAwarePersistenceManagerFactoryProxy implements FactoryBe
|
||||
public void setTargetPersistenceManagerFactory(PersistenceManagerFactory target) {
|
||||
Assert.notNull(target, "Target PersistenceManagerFactory must not be null");
|
||||
this.target = target;
|
||||
Class[] ifcs = ClassUtils.getAllInterfacesForClass(target.getClass(), target.getClass().getClassLoader());
|
||||
Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(target.getClass(), target.getClass().getClassLoader());
|
||||
this.proxy = (PersistenceManagerFactory) Proxy.newProxyInstance(
|
||||
target.getClass().getClassLoader(), ifcs, new PersistenceManagerFactoryInvocationHandler());
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class TransactionAwarePersistenceManagerFactoryProxy implements FactoryBe
|
||||
PersistenceManagerFactory target = getTargetPersistenceManagerFactory();
|
||||
PersistenceManager pm =
|
||||
PersistenceManagerFactoryUtils.doGetPersistenceManager(target, isAllowCreate());
|
||||
Class[] ifcs = ClassUtils.getAllInterfacesForClass(pm.getClass(), pm.getClass().getClassLoader());
|
||||
Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(pm.getClass(), pm.getClass().getClassLoader());
|
||||
return Proxy.newProxyInstance(
|
||||
pm.getClass().getClassLoader(), ifcs, new PersistenceManagerInvocationHandler(pm, target));
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class SpringPersistenceManagerProxyBean implements FactoryBean<Persistenc
|
||||
}
|
||||
this.proxy = (PersistenceManager) Proxy.newProxyInstance(
|
||||
getPersistenceManagerFactory().getClass().getClassLoader(),
|
||||
new Class[] {getPersistenceManagerInterface()}, new PersistenceManagerInvocationHandler());
|
||||
new Class<?>[] {getPersistenceManagerInterface()}, new PersistenceManagerInvocationHandler());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @see LocalEntityManagerFactoryBean
|
||||
* @see LocalContainerEntityManagerFactoryBean
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class AbstractEntityManagerFactoryBean implements
|
||||
FactoryBean<EntityManagerFactory>, BeanClassLoaderAware, BeanFactoryAware, BeanNameAware,
|
||||
InitializingBean, DisposableBean, EntityManagerFactoryInfo, PersistenceExceptionTranslator, Serializable {
|
||||
@@ -338,7 +339,7 @@ public abstract class AbstractEntityManagerFactoryBean implements
|
||||
* @return proxy entity manager
|
||||
*/
|
||||
protected EntityManagerFactory createEntityManagerFactoryProxy(EntityManagerFactory emf) {
|
||||
Set<Class> ifcs = new LinkedHashSet<Class>();
|
||||
Set<Class<?>> ifcs = new LinkedHashSet<Class<?>>();
|
||||
if (this.entityManagerFactoryInterface != null) {
|
||||
ifcs.add(this.entityManagerFactoryInterface);
|
||||
}
|
||||
@@ -348,7 +349,7 @@ public abstract class AbstractEntityManagerFactoryBean implements
|
||||
ifcs.add(EntityManagerFactoryInfo.class);
|
||||
try {
|
||||
return (EntityManagerFactory) Proxy.newProxyInstance(
|
||||
this.beanClassLoader, ifcs.toArray(new Class[ifcs.size()]),
|
||||
this.beanClassLoader, ifcs.toArray(new Class<?>[ifcs.size()]),
|
||||
new ManagedEntityManagerFactoryInvocationHandler(this));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
@@ -378,7 +379,7 @@ public abstract class AbstractEntityManagerFactoryBean implements
|
||||
// JPA 2.1's createEntityManager(SynchronizationType, Map)
|
||||
// Redirect to plain createEntityManager and add synchronization semantics through Spring proxy
|
||||
EntityManager rawEntityManager = (args.length > 1 ?
|
||||
this.nativeEntityManagerFactory.createEntityManager((Map) args[1]) :
|
||||
this.nativeEntityManagerFactory.createEntityManager((Map<?, ?>) args[1]) :
|
||||
this.nativeEntityManagerFactory.createEntityManager());
|
||||
return ExtendedEntityManagerCreator.createApplicationManagedEntityManager(rawEntityManager, this, true);
|
||||
}
|
||||
@@ -532,7 +533,7 @@ public abstract class AbstractEntityManagerFactoryBean implements
|
||||
}
|
||||
else if (method.getName().equals("unwrap")) {
|
||||
// Handle JPA 2.1 unwrap method - could be a proxy match.
|
||||
Class targetClass = (Class) args[0];
|
||||
Class<?> targetClass = (Class<?>) args[0];
|
||||
if (targetClass == null || targetClass.isInstance(proxy)) {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.orm.jpa;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityExistsException;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
@@ -34,7 +35,6 @@ import javax.persistence.TransactionRequiredException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
@@ -66,6 +66,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class EntityManagerFactoryUtils {
|
||||
|
||||
/**
|
||||
@@ -85,7 +86,7 @@ public abstract class EntityManagerFactoryUtils {
|
||||
|
||||
static {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings( "rawtypes" )
|
||||
Class<Enum> synchronizationTypeClass = (Class<Enum>) ClassUtils.forName(
|
||||
"javax.persistence.SynchronizationType", EntityManagerFactoryUtils.class.getClassLoader());
|
||||
createEntityManagerWithSynchronizationTypeMethod = EntityManagerFactory.class.getMethod(
|
||||
@@ -170,7 +171,7 @@ public abstract class EntityManagerFactoryUtils {
|
||||
* @throws DataAccessResourceFailureException if the EntityManager couldn't be obtained
|
||||
* @see JpaTransactionManager
|
||||
*/
|
||||
public static EntityManager getTransactionalEntityManager(EntityManagerFactory emf, Map properties)
|
||||
public static EntityManager getTransactionalEntityManager(EntityManagerFactory emf, Map<?, ?> properties)
|
||||
throws DataAccessResourceFailureException {
|
||||
try {
|
||||
return doGetTransactionalEntityManager(emf, properties, true);
|
||||
@@ -193,7 +194,7 @@ public abstract class EntityManagerFactoryUtils {
|
||||
* @see #getTransactionalEntityManager(javax.persistence.EntityManagerFactory)
|
||||
* @see JpaTransactionManager
|
||||
*/
|
||||
public static EntityManager doGetTransactionalEntityManager(EntityManagerFactory emf, Map properties)
|
||||
public static EntityManager doGetTransactionalEntityManager(EntityManagerFactory emf, Map<?, ?> properties)
|
||||
throws PersistenceException {
|
||||
|
||||
return doGetTransactionalEntityManager(emf, properties, true);
|
||||
@@ -215,7 +216,7 @@ public abstract class EntityManagerFactoryUtils {
|
||||
* @see JpaTransactionManager
|
||||
*/
|
||||
public static EntityManager doGetTransactionalEntityManager(
|
||||
EntityManagerFactory emf, Map properties, boolean synchronizedWithTransaction) throws PersistenceException {
|
||||
EntityManagerFactory emf, Map<?, ?> properties, boolean synchronizedWithTransaction) throws PersistenceException {
|
||||
|
||||
Assert.notNull(emf, "No EntityManagerFactory specified");
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class ExtendedEntityManagerCreator {
|
||||
* in any managed transaction
|
||||
* @see javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map)
|
||||
*/
|
||||
public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, Map properties) {
|
||||
public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, Map<?, ?> properties) {
|
||||
return createContainerManagedEntityManager(emf, properties, true);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public abstract class ExtendedEntityManagerCreator {
|
||||
* @see javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map)
|
||||
*/
|
||||
public static EntityManager createContainerManagedEntityManager(
|
||||
EntityManagerFactory emf, Map properties, boolean synchronizedWithTransaction) {
|
||||
EntityManagerFactory emf, Map<?, ?> properties, boolean synchronizedWithTransaction) {
|
||||
|
||||
Assert.notNull(emf, "EntityManagerFactory must not be null");
|
||||
if (emf instanceof EntityManagerFactoryInfo) {
|
||||
@@ -211,7 +211,7 @@ public abstract class ExtendedEntityManagerCreator {
|
||||
boolean containerManaged, boolean synchronizedWithTransaction) {
|
||||
|
||||
Assert.notNull(rawEm, "EntityManager must not be null");
|
||||
Set<Class> ifcs = new LinkedHashSet<Class>();
|
||||
Set<Class<?>> ifcs = new LinkedHashSet<Class<?>>();
|
||||
if (emIfc != null) {
|
||||
ifcs.add(emIfc);
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public abstract class ExtendedEntityManagerCreator {
|
||||
ifcs.add(EntityManagerProxy.class);
|
||||
return (EntityManager) Proxy.newProxyInstance(
|
||||
(cl != null ? cl : ExtendedEntityManagerCreator.class.getClassLoader()),
|
||||
ifcs.toArray(new Class[ifcs.size()]),
|
||||
ifcs.toArray(new Class<?>[ifcs.size()]),
|
||||
new ExtendedEntityManagerInvocationHandler(
|
||||
rawEm, exceptionTranslator, jta, containerManaged, synchronizedWithTransaction));
|
||||
}
|
||||
@@ -285,7 +285,7 @@ public abstract class ExtendedEntityManagerCreator {
|
||||
}
|
||||
else if (method.getName().equals("unwrap")) {
|
||||
// Handle JPA 2.0 unwrap method - could be a proxy match.
|
||||
Class targetClass = (Class) args[0];
|
||||
Class<?> targetClass = (Class<?>) args[0];
|
||||
if (targetClass == null || targetClass.isInstance(proxy)) {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public abstract class SharedEntityManagerCreator {
|
||||
* {@code createEntityManager} call (may be {@code null})
|
||||
* @return a shareable transaction EntityManager proxy
|
||||
*/
|
||||
public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map properties) {
|
||||
public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?, ?> properties) {
|
||||
return createSharedEntityManager(emf, properties, true);
|
||||
}
|
||||
|
||||
@@ -87,11 +87,11 @@ public abstract class SharedEntityManagerCreator {
|
||||
* @return a shareable transaction EntityManager proxy
|
||||
*/
|
||||
public static EntityManager createSharedEntityManager(
|
||||
EntityManagerFactory emf, Map properties, boolean synchronizedWithTransaction) {
|
||||
EntityManagerFactory emf, Map<?, ?> properties, boolean synchronizedWithTransaction) {
|
||||
Class<?> entityManagerInterface = (emf instanceof EntityManagerFactoryInfo ?
|
||||
((EntityManagerFactoryInfo) emf).getEntityManagerInterface() : EntityManager.class);
|
||||
return createSharedEntityManager(emf, properties, synchronizedWithTransaction,
|
||||
(entityManagerInterface == null ? NO_ENTITY_MANAGER_INTERFACES :
|
||||
return createSharedEntityManager(emf, properties, synchronizedWithTransaction,
|
||||
(entityManagerInterface == null ? NO_ENTITY_MANAGER_INTERFACES :
|
||||
new Class<?>[] { entityManagerInterface }));
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public abstract class SharedEntityManagerCreator {
|
||||
* @return a shareable transactional EntityManager proxy
|
||||
*/
|
||||
public static EntityManager createSharedEntityManager(
|
||||
EntityManagerFactory emf, Map properties, Class... entityManagerInterfaces) {
|
||||
EntityManagerFactory emf, Map<?, ?> properties, Class<?>... entityManagerInterfaces) {
|
||||
|
||||
return createSharedEntityManager(emf, properties, true, entityManagerInterfaces);
|
||||
}
|
||||
@@ -121,14 +121,14 @@ public abstract class SharedEntityManagerCreator {
|
||||
* EntityManager. Allows the addition or specification of proprietary interfaces.
|
||||
* @return a shareable transactional EntityManager proxy
|
||||
*/
|
||||
public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map properties,
|
||||
boolean synchronizedWithTransaction, Class... entityManagerInterfaces) {
|
||||
public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?, ?> properties,
|
||||
boolean synchronizedWithTransaction, Class<?>... entityManagerInterfaces) {
|
||||
|
||||
ClassLoader cl = null;
|
||||
if (emf instanceof EntityManagerFactoryInfo) {
|
||||
cl = ((EntityManagerFactoryInfo) emf).getBeanClassLoader();
|
||||
}
|
||||
Class[] ifcs = new Class[entityManagerInterfaces.length + 1];
|
||||
Class<?>[] ifcs = new Class<?>[entityManagerInterfaces.length + 1];
|
||||
System.arraycopy(entityManagerInterfaces, 0, ifcs, 0, entityManagerInterfaces.length);
|
||||
ifcs[entityManagerInterfaces.length] = EntityManagerProxy.class;
|
||||
return (EntityManager) Proxy.newProxyInstance(
|
||||
@@ -149,14 +149,14 @@ public abstract class SharedEntityManagerCreator {
|
||||
|
||||
private final EntityManagerFactory targetFactory;
|
||||
|
||||
private final Map properties;
|
||||
private final Map<?, ?> properties;
|
||||
|
||||
private final boolean synchronizedWithTransaction;
|
||||
|
||||
private transient volatile ClassLoader proxyClassLoader;
|
||||
|
||||
public SharedEntityManagerInvocationHandler(
|
||||
EntityManagerFactory target, Map properties, boolean synchronizedWithTransaction) {
|
||||
EntityManagerFactory target, Map<?, ?> properties, boolean synchronizedWithTransaction) {
|
||||
this.targetFactory = target;
|
||||
this.properties = properties;
|
||||
this.synchronizedWithTransaction = synchronizedWithTransaction;
|
||||
@@ -203,7 +203,7 @@ public abstract class SharedEntityManagerCreator {
|
||||
}
|
||||
else if (method.getName().equals("unwrap")) {
|
||||
// JPA 2.0: handle unwrap method - could be a proxy match.
|
||||
Class targetClass = (Class) args[0];
|
||||
Class<?> targetClass = (Class<?>) args[0];
|
||||
if (targetClass == null || targetClass.isInstance(proxy)) {
|
||||
return proxy;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ public abstract class SharedEntityManagerCreator {
|
||||
if (result instanceof Query) {
|
||||
Query query = (Query) result;
|
||||
if (isNewEm) {
|
||||
Class[] ifcs = ClassUtils.getAllInterfacesForClass(query.getClass(), this.proxyClassLoader);
|
||||
Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(query.getClass(), this.proxyClassLoader);
|
||||
result = Proxy.newProxyInstance(this.proxyClassLoader, ifcs,
|
||||
new DeferredQueryInvocationHandler(query, target));
|
||||
isNewEm = false;
|
||||
@@ -317,7 +317,7 @@ public abstract class SharedEntityManagerCreator {
|
||||
}
|
||||
else if (method.getName().equals("unwrap")) {
|
||||
// Handle JPA 2.0 unwrap method - could be a proxy match.
|
||||
Class targetClass = (Class) args[0];
|
||||
Class<?> targetClass = (Class<?>) args[0];
|
||||
if (targetClass == null || targetClass.isInstance(proxy)) {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.orm.jpa.support;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
@@ -33,8 +32,8 @@ import org.springframework.orm.jpa.EntityManagerHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.async.*;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.orm.jpa.support;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
@@ -28,9 +27,7 @@ import org.springframework.orm.jpa.EntityManagerHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.orm.jpa.vendor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.spi.PersistenceProvider;
|
||||
@@ -32,11 +33,9 @@ import org.hibernate.dialect.MySQLDialect;
|
||||
import org.hibernate.dialect.Oracle9iDialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.dialect.SQLServerDialect;
|
||||
import org.hibernate.dialect.SybaseDialect;
|
||||
import org.hibernate.ejb.HibernateEntityManager;
|
||||
import org.hibernate.ejb.HibernateEntityManagerFactory;
|
||||
import org.hibernate.ejb.HibernatePersistence;
|
||||
|
||||
import org.springframework.orm.jpa.JpaDialect;
|
||||
|
||||
/**
|
||||
@@ -77,7 +76,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
|
||||
jpaProperties.put(Environment.DIALECT, getDatabasePlatform());
|
||||
}
|
||||
else if (getDatabase() != null) {
|
||||
Class databaseDialectClass = determineDatabaseDialectClass(getDatabase());
|
||||
Class<?> databaseDialectClass = determineDatabaseDialectClass(getDatabase());
|
||||
if (databaseDialectClass != null) {
|
||||
jpaProperties.put(Environment.DIALECT, databaseDialectClass.getName());
|
||||
}
|
||||
@@ -98,7 +97,8 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
|
||||
* @param database the target database
|
||||
* @return the Hibernate database dialect class, or {@code null} if none found
|
||||
*/
|
||||
protected Class determineDatabaseDialectClass(Database database) {
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Class<?> determineDatabaseDialectClass(Database database) {
|
||||
switch (database) {
|
||||
case DB2: return DB2Dialect.class;
|
||||
case DERBY: return DerbyDialect.class;
|
||||
@@ -109,7 +109,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
|
||||
case ORACLE: return Oracle9iDialect.class;
|
||||
case POSTGRESQL: return PostgreSQLDialect.class;
|
||||
case SQL_SERVER: return SQLServerDialect.class;
|
||||
case SYBASE: return SybaseDialect.class;
|
||||
case SYBASE: return org.hibernate.dialect.SybaseDialect.class;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user