Skip to content

Commit d4b2af9

Browse files
dreab8Sanne
authored andcommitted
HHH-15336 Deprecate SharedSessionContractImplementor#getTransactionStartTimestamp() and CacheTransactionSynchronization#getCurrentTransactionStartTimestamp()
1 parent a4b47d3 commit d4b2af9

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingTransactionSynchronizationImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ public class NoCachingTransactionSynchronizationImpl extends AbstractCacheTransa
1616
public NoCachingTransactionSynchronizationImpl(RegionFactory regionFactory) {
1717
super( regionFactory );
1818
}
19+
20+
@Override
21+
public long getCachingTimestamp() {
22+
throw new UnsupportedOperationException( "Method not supported when 2LC is not enabled" );
23+
}
1924
}

hibernate-core/src/main/java/org/hibernate/cache/spi/CacheTransactionSynchronization.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,29 @@ public interface CacheTransactionSynchronization {
4848
*
4949
* @implSpec This "timestamp" need not be related to timestamp in the Java
5050
* Date/millisecond sense. It just needs to be an incrementing value.
51+
*
52+
* @deprecated Use {@link CacheTransactionSynchronization#getCachingTimestamp()} instead.
5153
*/
54+
@Deprecated
5255
long getCurrentTransactionStartTimestamp();
5356

57+
/**
58+
* What is the start time of this context object?
59+
*
60+
* @apiNote If not currently joined to a transaction, the timestamp from
61+
* the last transaction is safe to use. If not ever/yet joined to a
62+
* transaction, a timestamp at the time the Session/CacheTransactionSynchronization
63+
* were created should be returned.
64+
*
65+
* @implSpec This "timestamp" need not be related to timestamp in the Java
66+
* Date/millisecond sense. It just needs to be an incrementing value.
67+
*
68+
* An UnsupportedOperationException is thrown if the Second Level Cache has not been enabled
69+
*/
70+
default long getCachingTimestamp(){
71+
return getCurrentTransactionStartTimestamp();
72+
}
73+
5474
/**
5575
* Callback that owning Session has become joined to a resource transaction.
5676
*

hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ default void checkOpen() {
167167
* @apiNote This "timestamp" need not be related to timestamp in the Java Date/millisecond
168168
* sense. It just needs to be an incrementing value. See
169169
* {@link CacheTransactionSynchronization#getCurrentTransactionStartTimestamp()}
170+
*
171+
* @deprecated no longer supported, when the Second Level Cache is enabled {{@link CacheTransactionSynchronization#getCachingTimestamp()}} can be used.
170172
*/
173+
@Deprecated
171174
long getTransactionStartTimestamp();
172175

173176
/**

0 commit comments

Comments
 (0)