@@ -87,10 +87,9 @@ public class CurrentTimestampGeneration implements BeforeExecutionGenerator, OnE
87
87
public static final String CLOCK_SETTING_NAME = "hibernate.testing.clock" ;
88
88
89
89
private final EnumSet <EventType > eventTypes ;
90
-
91
90
private final JavaType <Object > propertyType ;
92
-
93
91
private final CurrentTimestampGeneratorDelegate delegate ;
92
+
94
93
private static final Map <Class <?>, BiFunction <@ Nullable Clock , Integer , CurrentTimestampGeneratorDelegate >> GENERATOR_PRODUCERS = new HashMap <>();
95
94
private static final Map <Key , CurrentTimestampGeneratorDelegate > GENERATOR_DELEGATES = new ConcurrentHashMap <>();
96
95
@@ -192,11 +191,6 @@ public class CurrentTimestampGeneration implements BeforeExecutionGenerator, OnE
192
191
);
193
192
}
194
193
195
- private static JavaType <Object > getPropertyType (GeneratorCreationContext context ) {
196
- return context .getDatabase ().getTypeConfiguration ().getJavaTypeRegistry ()
197
- .getDescriptor ( context .getProperty ().getType ().getReturnedClass () );
198
- }
199
-
200
194
public CurrentTimestampGeneration (CurrentTimestamp annotation , Member member , GeneratorCreationContext context ) {
201
195
delegate = getGeneratorDelegate ( annotation .source (), member , context );
202
196
eventTypes = fromArray ( annotation .event () );
@@ -268,6 +262,11 @@ public static <T extends Clock> T getClock(SessionFactory sessionFactory) {
268
262
return (T ) sessionFactory .getProperties ().get ( CLOCK_SETTING_NAME );
269
263
}
270
264
265
+ private static JavaType <Object > getPropertyType (GeneratorCreationContext context ) {
266
+ return context .getDatabase ().getTypeConfiguration ().getJavaTypeRegistry ()
267
+ .getDescriptor ( context .getProperty ().getType ().getReturnedClass () );
268
+ }
269
+
271
270
@ Override
272
271
public boolean generatedOnExecution () {
273
272
return delegate == null ;
@@ -316,8 +315,17 @@ private record Key(Class<?> clazz, @Nullable Clock clock, int precision) {
316
315
317
316
static Timestamp getCurrentTimestamp (SharedSessionContractImplementor session ) {
318
317
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 ) {
321
329
final JdbcCoordinator coordinator = session .getJdbcCoordinator ();
322
330
final StatementPreparer statementPreparer = coordinator .getStatementPreparer ();
323
331
PreparedStatement statement = null ;
0 commit comments