try to make test work on Maria

This commit is contained in:
Gavin King 2022-02-07 17:48:06 +01:00
parent addc3ea4c2
commit 285c2099c8
1 changed files with 13 additions and 13 deletions

View File

@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
@DomainModel(annotatedClasses = AvgFunctionTest.Value.class) @DomainModel(annotatedClasses = AvgFunctionTest.Score.class)
@SessionFactory @SessionFactory
public class AvgFunctionTest { public class AvgFunctionTest {
@ -18,17 +18,17 @@ public class AvgFunctionTest {
public void test(SessionFactoryScope scope) { public void test(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.persist( new Value(0) ); session.persist( new Score(0) );
session.persist( new Value(1) ); session.persist( new Score(1) );
session.persist( new Value(2) ); session.persist( new Score(2) );
session.persist( new Value(3) ); session.persist( new Score(3) );
assertThat( assertThat(
session.createQuery("select avg(value) from Value", Double.class) session.createQuery("select avg(doubleValue) from ScoreForAvg", Double.class)
.getSingleResult(), .getSingleResult(),
is(1.5) is(1.5)
); );
assertThat( assertThat(
session.createQuery("select avg(integerValue) from Value", Double.class) session.createQuery("select avg(integerValue) from ScoreForAvg", Double.class)
.getSingleResult(), .getSingleResult(),
is(1.5) is(1.5)
); );
@ -36,15 +36,15 @@ public class AvgFunctionTest {
); );
} }
@Entity(name="Value") @Entity(name="ScoreForAvg")
public static class Value { public static class Score {
public Value() {} public Score() {}
public Value(int value) { public Score(int value) {
this.value = value; this.doubleValue = value;
this.integerValue = value; this.integerValue = value;
} }
@Id @Id
double value; double doubleValue;
int integerValue; int integerValue;
} }