mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-23 07:11:55 +00:00
#1405 - ENH: add findSingleDecimal() and findSingleLong() alias methods for SqlQuery.findSingleAttribute() ...
This commit is contained in:
1 parent
7cbae758fc
commit
42f0b419e8
3 files changed
+58
-1
No files matched your search
@@ -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() {
|
||||
|
||||
|
||||
Reference in new issue
Block a user