From d8dd5e7c0d5ff6ae854c0ed82f1ef2e478aabcaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Cedomir=20Igaly?= Date: Thu, 26 Sep 2024 14:03:16 +0200 Subject: [PATCH] HHH-18377 Fixed bug with sequence resetting --- .../main/java/org/hibernate/id/uuid/UuidVersion6Strategy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/id/uuid/UuidVersion6Strategy.java b/hibernate-core/src/main/java/org/hibernate/id/uuid/UuidVersion6Strategy.java index 60f134d2d8..e773dbb658 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/uuid/UuidVersion6Strategy.java +++ b/hibernate-core/src/main/java/org/hibernate/id/uuid/UuidVersion6Strategy.java @@ -98,9 +98,9 @@ public class UuidVersion6Strategy implements UUIDGenerationStrategy, UuidValueGe private long getSequence(final long currentTimestamp) { lock.lock(); try { - if ( this.currentTimestamp > currentTimestamp ) { + if ( this.currentTimestamp < currentTimestamp ) { this.currentTimestamp = currentTimestamp; - clockSequence.set( 0 ); + clockSequence.updateAndGet( l -> l & 0x1FFFL ); } } finally {