#1405 - ENH: add findSingleDecimal() and findSingleLong() alias methods for SqlQuery.findSingleAttribute() ...

This commit is contained in:
rob bygrave
2018-06-08 02:19:36 +12:00
parent 7cbae758fc
commit 42f0b419e8
3 changed files with 58 additions and 1 deletions
@@ -39,7 +39,21 @@ public class SqlQueryTests extends BaseTestCase {
}
@Test
public void findSingleAttribute_decimal() {
public void findSingleDecimal() {
ResetBasicData.reset();
String sql = "select max(unit_price) from o_order_detail where order_qty > ?";
BigDecimal maxPrice = Ebean.createSqlQuery(sql)
.setParameter(1, 2)
.findSingleDecimal();
assertThat(maxPrice).isNotNull();
}
@Test
public void findSingleAttribute_BigDecimal() {
ResetBasicData.reset();
@@ -52,6 +66,21 @@ public class SqlQueryTests extends BaseTestCase {
assertThat(maxPrice).isNotNull();
}
@Test
public void findSingleLong() {
ResetBasicData.reset();
String sql = "select count(order_qty) from o_order_detail where unit_price > ?";
long count = Ebean.createSqlQuery(sql)
.setParameter(1, 2)
.findSingleLong();
assertThat(count).isGreaterThan(0);
}
@Test
public void findSingleAttribute_long() {