use of org.apache.cayenne.testdo.numeric_types.BigDecimalEntity in project cayenne by apache.
the class NumericTypesIT method testBigDecimal.
@Test
public void testBigDecimal() throws Exception {
BigDecimalEntity test = context.newObject(BigDecimalEntity.class);
BigDecimal i = new BigDecimal("1234567890.44");
test.setBigDecimalField(i);
context.commitChanges();
SelectQuery<BigDecimalEntity> q = new SelectQuery<>(BigDecimalEntity.class);
BigDecimalEntity testRead = (BigDecimalEntity) context.performQuery(q).get(0);
assertNotNull(testRead.getBigDecimalField());
assertEquals(i, testRead.getBigDecimalField());
test.setBigDecimalField(null);
context.commitChanges();
}
use of org.apache.cayenne.testdo.numeric_types.BigDecimalEntity in project cayenne by apache.
the class DataContextEJBQLNumericalFunctionalIT method testSQRT.
@Test
public void testSQRT() {
BigDecimalEntity o1 = context.newObject(BigDecimalEntity.class);
o1.setBigDecimalField(new BigDecimal("9"));
BigDecimalEntity o2 = context.newObject(BigDecimalEntity.class);
o2.setBigDecimalField(new BigDecimal("16"));
context.commitChanges();
EJBQLQuery query = new EJBQLQuery("SELECT d FROM BigDecimalEntity d WHERE SQRT(d.bigDecimalField) > 3.1");
List<?> objects = context.performQuery(query);
assertEquals(1, objects.size());
assertTrue(objects.contains(o2));
}
use of org.apache.cayenne.testdo.numeric_types.BigDecimalEntity in project cayenne by apache.
the class DataContextEJBQLNumericalFunctionalIT method testABS.
@Test
public void testABS() {
BigDecimalEntity o1 = context.newObject(BigDecimalEntity.class);
o1.setBigDecimalField(new BigDecimal("4.1"));
BigDecimalEntity o2 = context.newObject(BigDecimalEntity.class);
o2.setBigDecimalField(new BigDecimal("-5.1"));
context.commitChanges();
EJBQLQuery query = new EJBQLQuery("SELECT d FROM BigDecimalEntity d WHERE ABS(d.bigDecimalField) < 5.0");
List<?> objects = context.performQuery(query);
assertEquals(1, objects.size());
assertTrue(objects.contains(o1));
}
Aggregations