Polishing

This commit is contained in:
Juergen Hoeller
2014-08-11 15:45:54 +02:00
parent 1034b0dae2
commit e2d71a8ccd
7 changed files with 33 additions and 22 deletions

View File

@@ -91,6 +91,9 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
* support nested transactions! Hence, do not expect Hibernate access code to * support nested transactions! Hence, do not expect Hibernate access code to
* semantically participate in a nested transaction.</i> * semantically participate in a nested transaction.</i>
* *
* <p><b>NOTE: Hibernate 4.2+ is strongly recommended for efficient transaction
* management with Spring, in particular for transactional Spring JDBC access.</b>
*
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1
* @see #setSessionFactory * @see #setSessionFactory
@@ -437,7 +440,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana
throw new InvalidIsolationLevelException( throw new InvalidIsolationLevelException(
"HibernateTransactionManager is not allowed to support custom isolation levels: " + "HibernateTransactionManager is not allowed to support custom isolation levels: " +
"make sure that its 'prepareConnection' flag is on (the default) and that the " + "make sure that its 'prepareConnection' flag is on (the default) and that the " +
"Hibernate connection release mode is set to 'on_close' (SpringTransactionFactory's default)."); "Hibernate connection release mode is set to 'on_close' (the default for JDBC).");
} }
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Not preparing JDBC Connection of Hibernate Session [" + session + "]"); logger.debug("Not preparing JDBC Connection of Hibernate Session [" + session + "]");

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -79,8 +79,8 @@ public class SpringSessionContext implements CurrentSessionContext {
else if (value instanceof SessionHolder) { else if (value instanceof SessionHolder) {
SessionHolder sessionHolder = (SessionHolder) value; SessionHolder sessionHolder = (SessionHolder) value;
Session session = sessionHolder.getSession(); Session session = sessionHolder.getSession();
if (TransactionSynchronizationManager.isSynchronizationActive() && if (!sessionHolder.isSynchronizedWithTransaction() &&
!sessionHolder.isSynchronizedWithTransaction()) { TransactionSynchronizationManager.isSynchronizationActive()) {
TransactionSynchronizationManager.registerSynchronization( TransactionSynchronizationManager.registerSynchronization(
new SpringSessionSynchronization(sessionHolder, this.sessionFactory)); new SpringSessionSynchronization(sessionHolder, this.sessionFactory));
sessionHolder.setSynchronizedWithTransaction(true); sessionHolder.setSynchronizedWithTransaction(true);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -30,7 +30,8 @@ import org.springframework.orm.jpa.JpaDialect;
/** /**
* {@link org.springframework.orm.jpa.JpaVendorAdapter} implementation for Eclipse * {@link org.springframework.orm.jpa.JpaVendorAdapter} implementation for Eclipse
* Persistence Services (EclipseLink). Developed and tested against EclipseLink 2.4. * Persistence Services (EclipseLink). Developed and tested against EclipseLink 2.4;
* compatible with EclipseLink 2.5 as well.
* *
* <p>Exposes EclipseLink's persistence provider and EntityManager extension interface, * <p>Exposes EclipseLink's persistence provider and EntityManager extension interface,
* and supports {@link AbstractJpaVendorAdapter}'s common configuration settings. * and supports {@link AbstractJpaVendorAdapter}'s common configuration settings.
@@ -43,10 +44,10 @@ import org.springframework.orm.jpa.JpaDialect;
*/ */
public class EclipseLinkJpaVendorAdapter extends AbstractJpaVendorAdapter { public class EclipseLinkJpaVendorAdapter extends AbstractJpaVendorAdapter {
private final PersistenceProvider persistenceProvider = new org.eclipse.persistence.jpa.PersistenceProvider();
private final JpaDialect jpaDialect = new EclipseLinkJpaDialect(); private final JpaDialect jpaDialect = new EclipseLinkJpaDialect();
private final PersistenceProvider persistenceProvider = new org.eclipse.persistence.jpa.PersistenceProvider();
@Override @Override
public PersistenceProvider getPersistenceProvider() { public PersistenceProvider getPersistenceProvider() {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -45,11 +45,11 @@ import org.springframework.orm.jpa.JpaDialect;
* <p>Exposes Hibernate's persistence provider and EntityManager extension interface, * <p>Exposes Hibernate's persistence provider and EntityManager extension interface,
* and supports {@link AbstractJpaVendorAdapter}'s common configuration settings. * and supports {@link AbstractJpaVendorAdapter}'s common configuration settings.
* *
* <p>Note that the package location of Hibernate's JPA support changed from 4.2 to 4.3: * <p>Note that the Java package location of Hibernate's JPA support changed from
* from {@code org.hibernate.ejb.HibernateEntityManager(Factory)} to * 4.2 to 4.3: from {@code org.hibernate.ejb.HibernateEntityManager(Factory)} to
* {@code org.hibernate.jpa.HibernateEntityManager(Factory)}. As of Spring 4.0, * {@code org.hibernate.jpa.HibernateEntityManager(Factory)}.
* we're exposing the correct, non-deprecated variant depending on the Hibernate * As of Spring 4.0, we are exposing the appropriate, non-deprecated variant -
* version encountered at runtime, in order to avoid deprecation log entries. * depending on the specific Hibernate version encountered at runtime.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Rod Johnson * @author Rod Johnson

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import org.springframework.orm.jpa.JpaDialect;
/** /**
* {@link org.springframework.orm.jpa.JpaVendorAdapter} implementation for Apache OpenJPA. * {@link org.springframework.orm.jpa.JpaVendorAdapter} implementation for Apache OpenJPA.
* Developed and tested against OpenJPA 2.2. * Developed and tested against OpenJPA 2.2; compatible with OpenJPA 2.3 as well.
* *
* <p>Exposes OpenJPA's persistence provider and EntityManager extension interface, * <p>Exposes OpenJPA's persistence provider and EntityManager extension interface,
* and supports {@link AbstractJpaVendorAdapter}'s common configuration settings. * and supports {@link AbstractJpaVendorAdapter}'s common configuration settings.
@@ -43,9 +43,9 @@ import org.springframework.orm.jpa.JpaDialect;
*/ */
public class OpenJpaVendorAdapter extends AbstractJpaVendorAdapter { public class OpenJpaVendorAdapter extends AbstractJpaVendorAdapter {
private final PersistenceProvider persistenceProvider = new PersistenceProviderImpl(); private final JpaDialect jpaDialect = new OpenJpaDialect();
private final OpenJpaDialect jpaDialect = new OpenJpaDialect(); private final PersistenceProvider persistenceProvider = new PersistenceProviderImpl();
@Override @Override

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1272,6 +1272,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
this.logger = LogFactory.getLog(getClass()); this.logger = LogFactory.getLog(getClass());
} }
/** /**
* Holder for suspended resources. * Holder for suspended resources.
* Used internally by {@code suspend} and {@code resume}. * Used internally by {@code suspend} and {@code resume}.
@@ -1279,10 +1280,15 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
protected static class SuspendedResourcesHolder { protected static class SuspendedResourcesHolder {
private final Object suspendedResources; private final Object suspendedResources;
private List<TransactionSynchronization> suspendedSynchronizations; private List<TransactionSynchronization> suspendedSynchronizations;
private String name; private String name;
private boolean readOnly; private boolean readOnly;
private Integer isolationLevel; private Integer isolationLevel;
private boolean wasActive; private boolean wasActive;
private SuspendedResourcesHolder(Object suspendedResources) { private SuspendedResourcesHolder(Object suspendedResources) {

View File

@@ -276,12 +276,13 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> pathVars = (this.exposePathVariables ? Map<String, Object> pathVars = (this.exposePathVariables ?
(Map<String, Object>) request.getAttribute(View.PATH_VARIABLES) : null); (Map<String, Object>) request.getAttribute(View.PATH_VARIABLES) : null);
// Consolidate static and dynamic model attributes. // Consolidate static and dynamic model attributes.
int size = this.staticAttributes.size(); int size = this.staticAttributes.size();
size += (model != null) ? model.size() : 0; size += (model != null ? model.size() : 0);
size += (pathVars != null) ? pathVars.size() : 0; size += (pathVars != null ? pathVars.size() : 0);
Map<String, Object> mergedModel = new LinkedHashMap<String, Object>(size); Map<String, Object> mergedModel = new LinkedHashMap<String, Object>(size);
mergedModel.putAll(this.staticAttributes); mergedModel.putAll(this.staticAttributes);
if (pathVars != null) { if (pathVars != null) {