HHH-16072 Restore SPI removal SharedSessionContractImplementor.getTransactionStartTimestamp()

This commit is contained in:
Sanne Grinovero 2023-01-10 15:19:14 +00:00 committed by Sanne Grinovero
parent 800873c43d
commit 94054f6a57
7 changed files with 64 additions and 1 deletions

View File

@ -18,6 +18,11 @@ public class NoCachingTransactionSynchronizationImpl implements CacheTransaction
}
@Override
public long getCurrentTransactionStartTimestamp() {
return getCachingTimestamp();
}
@Override
public long getCachingTimestamp() {
throw new UnsupportedOperationException("Method not supported when 2LC is not enabled");

View File

@ -20,6 +20,12 @@ public abstract class AbstractCacheTransactionSynchronization implements CacheTr
this.regionFactory = regionFactory;
}
@Override
@Deprecated(forRemoval = true)
public long getCurrentTransactionStartTimestamp() {
return lastTransactionCompletionTimestamp;
}
@Override
public long getCachingTimestamp() {
return lastTransactionCompletionTimestamp;

View File

@ -38,6 +38,24 @@ package org.hibernate.cache.spi;
* @author Radim Vansa
*/
public interface CacheTransactionSynchronization {
/**
* What is the start time of this context object?
*
* @apiNote If not currently joined to a transaction, the timestamp from
* the last transaction is safe to use. If not ever/yet joined to a
* transaction, a timestamp at the time the Session/CacheTransactionSynchronization
* were created should be returned.
*
* @implSpec This "timestamp" need not be related to timestamp in the Java
* Date/millisecond sense. It just needs to be an incrementing value.
*
* @deprecated Use {@link CacheTransactionSynchronization#getCachingTimestamp()} instead.
* Please do implement also getCachingTimestamp, as its default implementation will be removed.
*/
@Deprecated(forRemoval = true)
long getCurrentTransactionStartTimestamp();
/**
* What is the start time of this context object?
*
@ -51,7 +69,9 @@ public interface CacheTransactionSynchronization {
*
* An UnsupportedOperationException is thrown if 2LC has not enabled
*/
long getCachingTimestamp();
default long getCachingTimestamp() {
return getCurrentTransactionStartTimestamp();
}
/**
* Callback that owning Session has become joined to a resource transaction.

View File

@ -258,6 +258,12 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
delegate.markForRollbackOnly();
}
@Override
@Deprecated(forRemoval = true)
public long getTransactionStartTimestamp() {
return delegate.getTransactionStartTimestamp();
}
@Override
public FlushModeType getFlushMode() {
return delegate.getFlushMode();

View File

@ -208,6 +208,18 @@ public interface SharedSessionContractImplementor
*/
void markForRollbackOnly();
/**
* A "timestamp" at or before the start of the current transaction.
*
* @apiNote This "timestamp" need not be related to timestamp in the Java Date/millisecond
* sense. It just needs to be an incrementing value. See
* {@link CacheTransactionSynchronization#getCurrentTransactionStartTimestamp()}
*
* @deprecated no longer supported, will be removed soon.
*/
@Deprecated(forRemoval = true)
long getTransactionStartTimestamp();
/**
* The current {@link CacheTransactionSynchronization} associated
* with this session. This may be {@code null} if the session is not

View File

@ -364,6 +364,11 @@ public class SharedSessionDelegatorBaseImpl implements SharedSessionContractImpl
delegate.markForRollbackOnly();
}
@Override
public long getTransactionStartTimestamp() {
return delegate.getTransactionStartTimestamp();
}
@Override
public CacheTransactionSynchronization getCacheTransactionSynchronization() {
return delegate.getCacheTransactionSynchronization();

View File

@ -513,6 +513,15 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
return cacheTransactionSync;
}
/**
* @deprecated This will be removed.
*/
@Override
@Deprecated(forRemoval = true)
public long getTransactionStartTimestamp() {
return getCacheTransactionSynchronization().getCachingTimestamp();
}
@Override
public Transaction beginTransaction() {
checkOpen();