Add more @Nullable parameters based on null usage
Issue: SPR-15540
This commit is contained in:
@@ -27,6 +27,7 @@ import javax.transaction.UserTransaction;
|
||||
import org.hibernate.TransactionException;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.jta.UserTransactionAdapter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -54,7 +55,7 @@ class ConfigurableJtaPlatform implements JtaPlatform {
|
||||
* @param ut the JTA UserTransaction reference (optional)
|
||||
* @param tsr the JTA 1.1 TransactionSynchronizationRegistry (optional)
|
||||
*/
|
||||
public ConfigurableJtaPlatform(TransactionManager tm, UserTransaction ut, TransactionSynchronizationRegistry tsr) {
|
||||
public ConfigurableJtaPlatform(TransactionManager tm, @Nullable UserTransaction ut, @Nullable TransactionSynchronizationRegistry tsr) {
|
||||
Assert.notNull(tm, "TransactionManager reference must not be null");
|
||||
this.transactionManager = tm;
|
||||
this.userTransaction = (ut != null ? ut : new UserTransactionAdapter(tm));
|
||||
|
||||
@@ -442,7 +442,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(final Class<T> entityClass, final Serializable id, final LockMode lockMode)
|
||||
public <T> T get(final Class<T> entityClass, final Serializable id, @Nullable final LockMode lockMode)
|
||||
throws DataAccessException {
|
||||
|
||||
return executeWithNativeSession(new HibernateCallback<T>() {
|
||||
@@ -464,7 +464,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(final String entityName, final Serializable id, final LockMode lockMode)
|
||||
public Object get(final String entityName, final Serializable id, @Nullable final LockMode lockMode)
|
||||
throws DataAccessException {
|
||||
|
||||
return executeWithNativeSession(new HibernateCallback<Object>() {
|
||||
@@ -486,7 +486,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T load(final Class<T> entityClass, final Serializable id, final LockMode lockMode)
|
||||
public <T> T load(final Class<T> entityClass, final Serializable id, @Nullable final LockMode lockMode)
|
||||
throws DataAccessException {
|
||||
|
||||
return executeWithNativeSession(new HibernateCallback<T>() {
|
||||
@@ -508,7 +508,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object load(final String entityName, final Serializable id, final LockMode lockMode)
|
||||
public Object load(final String entityName, final Serializable id, @Nullable final LockMode lockMode)
|
||||
throws DataAccessException {
|
||||
|
||||
return executeWithNativeSession(new HibernateCallback<Object>() {
|
||||
@@ -555,7 +555,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh(final Object entity, final LockMode lockMode) throws DataAccessException {
|
||||
public void refresh(final Object entity, @Nullable final LockMode lockMode) throws DataAccessException {
|
||||
executeWithNativeSession(new HibernateCallback<Object>() {
|
||||
@Override
|
||||
public Object doInHibernate(Session session) throws HibernateException {
|
||||
@@ -668,7 +668,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final Object entity, final LockMode lockMode) throws DataAccessException {
|
||||
public void update(final Object entity, @Nullable final LockMode lockMode) throws DataAccessException {
|
||||
executeWithNativeSession(new HibernateCallback<Object>() {
|
||||
@Override
|
||||
public Object doInHibernate(Session session) throws HibernateException {
|
||||
@@ -688,7 +688,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final String entityName, final Object entity, final LockMode lockMode)
|
||||
public void update(final String entityName, final Object entity, @Nullable final LockMode lockMode)
|
||||
throws DataAccessException {
|
||||
|
||||
executeWithNativeSession(new HibernateCallback<Object>() {
|
||||
@@ -810,7 +810,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(final Object entity, final LockMode lockMode) throws DataAccessException {
|
||||
public void delete(final Object entity, @Nullable final LockMode lockMode) throws DataAccessException {
|
||||
executeWithNativeSession(new HibernateCallback<Object>() {
|
||||
@Override
|
||||
public Object doInHibernate(Session session) throws HibernateException {
|
||||
@@ -830,7 +830,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(final String entityName, final Object entity, final LockMode lockMode)
|
||||
public void delete(final String entityName, final Object entity, @Nullable final LockMode lockMode)
|
||||
throws DataAccessException {
|
||||
|
||||
executeWithNativeSession(new HibernateCallback<Object>() {
|
||||
@@ -1074,7 +1074,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public <T> List<T> findByExample(
|
||||
final String entityName, final T exampleEntity, final int firstResult, final int maxResults)
|
||||
@Nullable final String entityName, final T exampleEntity, final int firstResult, final int maxResults)
|
||||
throws DataAccessException {
|
||||
|
||||
Assert.notNull(exampleEntity, "Example entity must not be null");
|
||||
|
||||
@@ -785,7 +785,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana
|
||||
this.newSession = false;
|
||||
}
|
||||
|
||||
public void setSessionHolder(SessionHolder sessionHolder) {
|
||||
public void setSessionHolder(@Nullable SessionHolder sessionHolder) {
|
||||
this.sessionHolder = sessionHolder;
|
||||
this.newSessionHolder = false;
|
||||
this.newSession = false;
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternUtils;
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -371,7 +372,7 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
|
||||
* @param resourceLoader the ResourceLoader to use (never {@code null})
|
||||
*/
|
||||
@Override
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
|
||||
this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ public abstract class ExtendedEntityManagerCreator {
|
||||
*/
|
||||
private static EntityManager createProxy(
|
||||
EntityManager rawEm, @Nullable Class<? extends EntityManager> emIfc, @Nullable ClassLoader cl,
|
||||
PersistenceExceptionTranslator exceptionTranslator, @Nullable Boolean jta,
|
||||
@Nullable PersistenceExceptionTranslator exceptionTranslator, @Nullable Boolean jta,
|
||||
boolean containerManaged, boolean synchronizedWithTransaction) {
|
||||
|
||||
Assert.notNull(rawEm, "EntityManager must not be null");
|
||||
|
||||
@@ -622,7 +622,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager
|
||||
private Object transactionData;
|
||||
|
||||
public void setEntityManagerHolder(
|
||||
EntityManagerHolder entityManagerHolder, boolean newEntityManagerHolder) {
|
||||
@Nullable EntityManagerHolder entityManagerHolder, boolean newEntityManagerHolder) {
|
||||
this.entityManagerHolder = entityManagerHolder;
|
||||
this.newEntityManagerHolder = newEntityManagerHolder;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.context.weaving.LoadTimeWeaverAware;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.instrument.classloading.LoadTimeWeaver;
|
||||
import org.springframework.jdbc.datasource.lookup.SingleDataSourceLookup;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager;
|
||||
import org.springframework.orm.jpa.persistenceunit.PersistenceUnitManager;
|
||||
import org.springframework.orm.jpa.persistenceunit.PersistenceUnitPostProcessor;
|
||||
@@ -311,7 +312,7 @@ public class LocalContainerEntityManagerFactoryBean extends AbstractEntityManage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
|
||||
this.internalPersistenceUnitManager.setResourceLoader(resourceLoader);
|
||||
}
|
||||
|
||||
|
||||
@@ -411,7 +411,7 @@ public class DefaultPersistenceUnitManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
|
||||
this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
|
||||
this.componentsIndex = CandidateComponentsIndexLoader.loadIndex(resourceLoader.getClassLoader());
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ public class PersistenceAnnotationBeanPostProcessor
|
||||
}
|
||||
|
||||
|
||||
private InjectionMetadata findPersistenceMetadata(String beanName, final Class<?> clazz, PropertyValues pvs) {
|
||||
private InjectionMetadata findPersistenceMetadata(String beanName, final Class<?> clazz, @Nullable PropertyValues pvs) {
|
||||
// Fall back to class name as cache key, for backwards compatibility with custom callers.
|
||||
String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName());
|
||||
// Quick check on the concurrent map first, with minimal locking.
|
||||
@@ -631,7 +631,7 @@ public class PersistenceAnnotationBeanPostProcessor
|
||||
|
||||
private Properties properties;
|
||||
|
||||
public PersistenceElement(Member member, AnnotatedElement ae, PropertyDescriptor pd) {
|
||||
public PersistenceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) {
|
||||
super(member, pd);
|
||||
PersistenceContext pc = ae.getAnnotation(PersistenceContext.class);
|
||||
PersistenceUnit pu = ae.getAnnotation(PersistenceUnit.class);
|
||||
|
||||
@@ -326,7 +326,7 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
|
||||
private final Integer previousIsolationLevel;
|
||||
|
||||
public SessionTransactionData(
|
||||
Session session, FlushMode previousFlushMode, Connection preparedCon, Integer previousIsolationLevel) {
|
||||
Session session, FlushMode previousFlushMode, @Nullable Connection preparedCon, @Nullable Integer previousIsolationLevel) {
|
||||
this.session = session;
|
||||
this.previousFlushMode = previousFlushMode;
|
||||
this.preparedCon = preparedCon;
|
||||
|
||||
Reference in New Issue
Block a user