Hibernate Reactive selects and stores a Clock
before application is given any control
#43577
Labels
Clock
before application is given any control
#43577
Describe the bug
Hibernate Reactive stores a
Clock
for use when injecting temporal values (e.g.,@CurrentTimestamp
or@CreationTimestamp
).This means the only way to set the time zone to UTC is to use system properties and/or the environment, which is painful. It requires you to update multiple build tasks (in Gradle) and ensure it's set properly in production before starting the app.
Also, there appears to be a
hibernate.testing.clock
property it checks during its Clock caching, but I have found no way to set that in Hibernate Reactive.Expected behavior
Users have an easy way to set the clock to UTC for dev and, more importantly, testing.
During my experience in tracking this down, the easiest method was thought to be using
@QuarkusMain
or@Observes StartupEvent,
but neither of these works because the Clock is cached prior to application code getting control.Actual behavior
The Clock is cached before any code can run.
This leaves the developer tracking down which build tasks need to be configured with JVM args to set the clock to their chosen timezone.
Additionally, when running without a build tool, you need to set the timezone via JVM args as well.
How to Reproduce?
@Entity
with@CreationTimestamp
./gradlew -Duser.timezone=UTC quarkusDev
orquarkus -Duser.timezone=UTC dev
Output of
uname -a
orver
macOS 14.6.1
Output of
java -version
21.0.1
Quarkus version or git rev
3.15.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Gradle 8.9
Additional information
No response
The text was updated successfully, but these errors were encountered: