use of org.apache.cayenne.testdo.numeric_types.BigIntegerEntity in project cayenne by apache.
the class DataContextEJBQLNumericalFunctionalIT method testMOD.
@Test
public void testMOD() {
BigIntegerEntity o1 = context.newObject(BigIntegerEntity.class);
o1.setBigIntegerField(new BigInteger("9"));
BigIntegerEntity o2 = context.newObject(BigIntegerEntity.class);
o2.setBigIntegerField(new BigInteger("10"));
context.commitChanges();
EJBQLQuery query = new EJBQLQuery("SELECT d FROM BigIntegerEntity d WHERE MOD(d.bigIntegerField, 4) = 2");
List<?> objects = context.performQuery(query);
assertEquals(1, objects.size());
assertTrue(objects.contains(o2));
}
use of org.apache.cayenne.testdo.numeric_types.BigIntegerEntity in project cayenne by apache.
the class NumericTypesIT method testBigInteger.
@Test
public void testBigInteger() throws Exception {
BigIntegerEntity test = context.newObject(BigIntegerEntity.class);
BigInteger i = new BigInteger("1234567890");
test.setBigIntegerField(i);
context.commitChanges();
SelectQuery<BigIntegerEntity> q = new SelectQuery<>(BigIntegerEntity.class);
BigIntegerEntity testRead = (BigIntegerEntity) context.performQuery(q).get(0);
assertNotNull(testRead.getBigIntegerField());
assertEquals(i, testRead.getBigIntegerField());
test.setBigIntegerField(null);
context.commitChanges();
}
use of org.apache.cayenne.testdo.numeric_types.BigIntegerEntity in project cayenne by apache.
the class NumericTypesIT method testBigIntegerColumnSelect.
@Test
public void testBigIntegerColumnSelect() {
BigIntegerEntity test = context.newObject(BigIntegerEntity.class);
BigInteger i = new BigInteger("1234567890");
test.setBigIntegerField(i);
context.commitChanges();
BigInteger readValue = ObjectSelect.query(BigIntegerEntity.class).column(BigIntegerEntity.BIG_INTEGER_FIELD).selectOne(context);
assertEquals(i, readValue);
Property<BigInteger> calculated = Property.create(ExpressionFactory.exp("bigIntegerField + 1"), BigInteger.class);
BigInteger readValue2 = ObjectSelect.query(BigIntegerEntity.class).column(calculated).selectOne(context);
assertEquals(i.add(BigInteger.ONE), readValue2);
}
Aggregations