Skip to content

Commit 1d909ca

Browse files
committed
fix crazy impl of DialectFeatureChecks.CurrentTimestampHasMicrosecondPrecision
1 parent 414b8c8 commit 1d909ca

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/generated/InDbGenerationsWithAnnotationsTests.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
*/
3636
@DomainModel( annotatedClasses = InDbGenerationsWithAnnotationsTests.AuditedEntity.class )
3737
@SessionFactory
38-
@RequiresDialectFeature(feature = DialectFeatureChecks.CurrentTimestampHasMicrosecondPrecision.class, comment = "Without this, we might not see an update to the timestamp")
38+
@RequiresDialectFeature(feature = DialectFeatureChecks.CurrentTimestampHasMicrosecondPrecision.class,
39+
comment = "Without this, we might not see an update to the timestamp")
3940
public class InDbGenerationsWithAnnotationsTests {
4041
@Test
4142
public void testGenerations(SessionFactoryScope scope) {
@@ -57,9 +58,7 @@ public void testGenerations(SessionFactoryScope scope) {
5758
waitALittle();
5859

5960
// then changing
60-
final AuditedEntity merged = scope.fromTransaction( session, (s) -> {
61-
return (AuditedEntity) session.merge( saved );
62-
} );
61+
final AuditedEntity merged = scope.fromTransaction( session, s -> s.merge( saved ) );
6362

6463
assertThat( merged ).isNotNull();
6564
assertThat( merged.createdOn ).isNotNull();
@@ -69,10 +68,8 @@ public void testGenerations(SessionFactoryScope scope) {
6968
//We need to wait a little to make sure the timestamps produced are different
7069
waitALittle();
7170

72-
// lastly, make sure we can load it..
73-
final AuditedEntity loaded = scope.fromTransaction( session, (s) -> {
74-
return session.get( AuditedEntity.class, 1 );
75-
} );
71+
// lastly, make sure we can load it
72+
final AuditedEntity loaded = scope.fromTransaction( session, s -> s.get( AuditedEntity.class, 1 ) );
7673

7774
assertThat( loaded ).isNotNull();
7875
assertThat( loaded.createdOn ).isEqualTo( merged.createdOn );

hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFeatureChecks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ public boolean apply(Dialect dialect) {
458458

459459
public static class CurrentTimestampHasMicrosecondPrecision implements DialectFeatureCheck {
460460
public boolean apply(Dialect dialect) {
461-
return !dialect.currentTimestamp().contains( "6" );
461+
return dialect.getDefaultTimestampPrecision() >= 6;
462462
}
463463
}
464464

0 commit comments

Comments
 (0)