Skip to content

Commit cf645b0

Browse files
committed
Make FormulaWithPartitionByTest deterministic and enable partition by tests on H2
1 parent d7a0fca commit cf645b0

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,11 @@ public String getCaseInsensitiveLike() {
10461046
}
10471047
}
10481048

1049+
@Override
1050+
public boolean supportsPartitionBy() {
1051+
return getVersion().isSameOrAfter( 1, 4, 200 );
1052+
}
1053+
10491054
@Override
10501055
public boolean supportsCaseInsensitiveLike() {
10511056
return getVersion().isSameOrAfter( 1, 4, 194 );

hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,11 @@ public boolean supportsCaseInsensitiveLike(){
10751075
return true;
10761076
}
10771077

1078+
@Override
1079+
public boolean supportsPartitionBy() {
1080+
return true;
1081+
}
1082+
10781083
@Override
10791084
public boolean supportsBindingNullSqlTypeForSetNull() {
10801085
return true;

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/formula/FormulaWithPartitionByTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ void tearDown(SessionFactoryScope scope) {
8282
public static class DisplayItem implements Serializable {
8383

8484
@Id
85+
@Column(name = "DISPLAY_ITEM_ID")
8586
private Integer id;
8687

8788
@Column(name = "DISCOUNT_CODE")
@@ -90,7 +91,7 @@ public static class DisplayItem implements Serializable {
9091
@Column(name = "DISCOUNT_VALUE")
9192
private Double discountValue;
9293

93-
@Formula("ROW_NUMBER() OVER( PARTITION BY DISCOUNT_CODE ORDER BY SIGN(DISCOUNT_VALUE) DESC )")
94+
@Formula("ROW_NUMBER() OVER(PARTITION BY DISCOUNT_CODE ORDER BY DISPLAY_ITEM_ID)")
9495
private Integer itemsByCode;
9596

9697
public Integer getId() {

0 commit comments

Comments
 (0)