mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Polishing
This commit is contained in:
@@ -69,6 +69,9 @@ public class DefaultJpaDialect implements JpaDialect, Serializable {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation simply returns {@code null} for no transaction data.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Object prepareTransaction(EntityManager entityManager, boolean readOnly, @Nullable String name)
|
||||
@@ -81,6 +84,7 @@ public class DefaultJpaDialect implements JpaDialect, Serializable {
|
||||
* This implementation does nothing, since the default {@code beginTransaction}
|
||||
* implementation does not require any cleanup.
|
||||
* @see #beginTransaction
|
||||
* @see #prepareTransaction
|
||||
*/
|
||||
@Override
|
||||
public void cleanupTransaction(@Nullable Object transactionData) {
|
||||
|
||||
@@ -100,7 +100,7 @@ public interface JpaDialect extends PersistenceExceptionTranslator {
|
||||
* @param readOnly whether the transaction is supposed to be read-only
|
||||
* @param name the name of the transaction (if any)
|
||||
* @return an arbitrary object that holds transaction data, if any
|
||||
* (to be passed into cleanupTransaction)
|
||||
* (to be passed into {@link #cleanupTransaction})
|
||||
* @throws jakarta.persistence.PersistenceException if thrown by JPA methods
|
||||
* @see #cleanupTransaction
|
||||
*/
|
||||
@@ -117,6 +117,7 @@ public interface JpaDialect extends PersistenceExceptionTranslator {
|
||||
* @param transactionData arbitrary object that holds transaction data, if any
|
||||
* (as returned by beginTransaction or prepareTransaction)
|
||||
* @see #beginTransaction
|
||||
* @see #prepareTransaction
|
||||
* @see org.springframework.jdbc.datasource.DataSourceUtils#resetConnectionAfterTransaction
|
||||
*/
|
||||
void cleanupTransaction(@Nullable Object transactionData);
|
||||
|
||||
+5
-3
@@ -181,16 +181,18 @@ public class EclipseLinkJpaDialect extends DefaultJpaDialect {
|
||||
|
||||
@Override
|
||||
public Connection getConnection() {
|
||||
if (this.connection == null) {
|
||||
Connection con = this.connection;
|
||||
if (con == null) {
|
||||
transactionIsolationLock.lock();
|
||||
try {
|
||||
this.connection = this.entityManager.unwrap(Connection.class);
|
||||
con = this.entityManager.unwrap(Connection.class);
|
||||
}
|
||||
finally {
|
||||
transactionIsolationLock.unlock();
|
||||
}
|
||||
this.connection = con;
|
||||
}
|
||||
return this.connection;
|
||||
return con;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user