Skip to content

Commit df6a1df

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

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
@@ -1055,6 +1055,11 @@ public boolean supportsCaseInsensitiveLike(){
10551055
return true;
10561056
}
10571057

1058+
@Override
1059+
public boolean supportsPartitionBy() {
1060+
return true;
1061+
}
1062+
10581063
@Override
10591064
public boolean supportsBindingNullSqlTypeForSetNull() {
10601065
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)