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
* 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
* @since 3.1
* @see #setSessionFactory
@@ -437,7 +440,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana
throw new InvalidIsolationLevelException(
"HibernateTransactionManager is not allowed to support custom isolation levels: " +
"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()) {
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");
* 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) {
SessionHolder sessionHolder = (SessionHolder) value;
Session session = sessionHolder.getSession();
if (TransactionSynchronizationManager.isSynchronizationActive() &&
!sessionHolder.isSynchronizedWithTransaction()) {
if (!sessionHolder.isSynchronizedWithTransaction() &&
TransactionSynchronizationManager.isSynchronizationActive()) {
TransactionSynchronizationManager.registerSynchronization(
new SpringSessionSynchronization(sessionHolder, this.sessionFactory));
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");
* 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
* 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,
* and supports {@link AbstractJpaVendorAdapter}'s common configuration settings.
@@ -43,10 +44,10 @@ import org.springframework.orm.jpa.JpaDialect;
*/
public class EclipseLinkJpaVendorAdapter extends AbstractJpaVendorAdapter {
private final PersistenceProvider persistenceProvider = new org.eclipse.persistence.jpa.PersistenceProvider();
private final JpaDialect jpaDialect = new EclipseLinkJpaDialect();
private final PersistenceProvider persistenceProvider = new org.eclipse.persistence.jpa.PersistenceProvider();
@Override
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");
* 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,
* 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:
* from {@code org.hibernate.ejb.HibernateEntityManager(Factory)} to
* {@code org.hibernate.jpa.HibernateEntityManager(Factory)}. As of Spring 4.0,
* we're exposing the correct, non-deprecated variant depending on the Hibernate
* version encountered at runtime, in order to avoid deprecation log entries.
* <p>Note that the Java package location of Hibernate's JPA support changed from
* 4.2 to 4.3: from {@code org.hibernate.ejb.HibernateEntityManager(Factory)} to
* {@code org.hibernate.jpa.HibernateEntityManager(Factory)}.
* As of Spring 4.0, we are exposing the appropriate, non-deprecated variant -
* depending on the specific Hibernate version encountered at runtime.
*
* @author Juergen Hoeller
* @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");
* 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.
* 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,
* and supports {@link AbstractJpaVendorAdapter}'s common configuration settings.
@@ -43,9 +43,9 @@ import org.springframework.orm.jpa.JpaDialect;
*/
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

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");
* 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());
}
/**
* Holder for suspended resources.
* Used internally by {@code suspend} and {@code resume}.
@@ -1279,10 +1280,15 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
protected static class SuspendedResourcesHolder {
private final Object suspendedResources;
private List<TransactionSynchronization> suspendedSynchronizations;
private String name;
private boolean readOnly;
private Integer isolationLevel;
private boolean wasActive;
private SuspendedResourcesHolder(Object suspendedResources) {

View File

@@ -276,12 +276,13 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
@SuppressWarnings("unchecked")
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.
int size = this.staticAttributes.size();
size += (model != null) ? model.size() : 0;
size += (pathVars != null) ? pathVars.size() : 0;
size += (model != null ? model.size() : 0);
size += (pathVars != null ? pathVars.size() : 0);
Map<String, Object> mergedModel = new LinkedHashMap<String, Object>(size);
mergedModel.putAll(this.staticAttributes);
if (pathVars != null) {