@@ -87,10 +87,9 @@ public class CurrentTimestampGeneration implements BeforeExecutionGenerator, OnE
8787 public static final String CLOCK_SETTING_NAME = "hibernate.testing.clock" ;
8888
8989 private final EnumSet <EventType > eventTypes ;
90-
9190 private final JavaType <Object > propertyType ;
92-
9391 private final CurrentTimestampGeneratorDelegate delegate ;
92+
9493 private static final Map <Class <?>, BiFunction <@ Nullable Clock , Integer , CurrentTimestampGeneratorDelegate >> GENERATOR_PRODUCERS = new HashMap <>();
9594 private static final Map <Key , CurrentTimestampGeneratorDelegate > GENERATOR_DELEGATES = new ConcurrentHashMap <>();
9695
@@ -192,11 +191,6 @@ public class CurrentTimestampGeneration implements BeforeExecutionGenerator, OnE
192191 );
193192 }
194193
195- private static JavaType <Object > getPropertyType (GeneratorCreationContext context ) {
196- return context .getDatabase ().getTypeConfiguration ().getJavaTypeRegistry ()
197- .getDescriptor ( context .getProperty ().getType ().getReturnedClass () );
198- }
199-
200194 public CurrentTimestampGeneration (CurrentTimestamp annotation , Member member , GeneratorCreationContext context ) {
201195 delegate = getGeneratorDelegate ( annotation .source (), member , context );
202196 eventTypes = fromArray ( annotation .event () );
@@ -268,6 +262,11 @@ public static <T extends Clock> T getClock(SessionFactory sessionFactory) {
268262 return (T ) sessionFactory .getProperties ().get ( CLOCK_SETTING_NAME );
269263 }
270264
265+ private static JavaType <Object > getPropertyType (GeneratorCreationContext context ) {
266+ return context .getDatabase ().getTypeConfiguration ().getJavaTypeRegistry ()
267+ .getDescriptor ( context .getProperty ().getType ().getReturnedClass () );
268+ }
269+
271270 @ Override
272271 public boolean generatedOnExecution () {
273272 return delegate == null ;
@@ -316,8 +315,17 @@ private record Key(Class<?> clazz, @Nullable Clock clock, int precision) {
316315
317316 static Timestamp getCurrentTimestamp (SharedSessionContractImplementor session ) {
318317 final Dialect dialect = session .getJdbcServices ().getJdbcEnvironment ().getDialect ();
319- final boolean callable = dialect .isCurrentTimestampSelectStringCallable ();
320- final String timestampSelectString = dialect .getCurrentTimestampSelectString ();
318+ return getCurrentTimestampFromDatabase (
319+ dialect .getCurrentTimestampSelectString (),
320+ dialect .isCurrentTimestampSelectStringCallable (),
321+ session
322+ );
323+ }
324+
325+ static Timestamp getCurrentTimestampFromDatabase (
326+ String timestampSelectString ,
327+ boolean callable ,
328+ SharedSessionContractImplementor session ) {
321329 final JdbcCoordinator coordinator = session .getJdbcCoordinator ();
322330 final StatementPreparer statementPreparer = coordinator .getStatementPreparer ();
323331 PreparedStatement statement = null ;
0 commit comments