Polishing

This commit is contained in:
Juergen Hoeller
2026-02-28 19:45:22 +01:00
parent 728466dce0
commit b426ef2d1b
3 changed files with 11 additions and 4 deletions
@@ -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);
@@ -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;
}
}