use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testDECIMAL2.
@Test
public void testDECIMAL2() throws Exception {
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
BigDecimal decimalValue = new BigDecimal("578438.57843");
test.setDecimalColumn(decimalValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
BigDecimal columnValue = testRead.getDecimalColumn();
assertNotNull(columnValue);
assertEquals(BigDecimal.class, columnValue.getClass());
assertEquals(decimalValue, columnValue);
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testTIMESTAMP2.
@Test
public void testTIMESTAMP2() throws Exception {
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Date timestampValue = Calendar.getInstance().getTime();
test.setTimestampColumn(timestampValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
Date columnValue = testRead.getTimestampColumn();
assertNotNull(columnValue);
assertEquals(Date.class, columnValue.getClass());
// some DB's, noteably MySQL, strip the milliseconds from timestamps,
// so comparing within 1 second precision
long delta = timestampValue.getTime() - ((Date) columnValue).getTime();
assertTrue(delta < 1000);
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testINTEGER2.
@Test
public void testINTEGER2() throws Exception {
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Integer integerValue = 54235;
test.setIntegerColumn(integerValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
Integer columnValue = testRead.getIntegerColumn();
assertNotNull(columnValue);
assertEquals(Integer.class, columnValue.getClass());
assertEquals(integerValue, columnValue);
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testBLOB2.
@Test
public void testBLOB2() throws Exception {
if (unitDbAdapter.supportsLobs()) {
ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
byte[] blobValue = { 3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60 };
test.setBlobColumn(blobValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap2.class);
ReturnTypesMap2 testRead = (ReturnTypesMap2) context.performQuery(q).get(0);
byte[] columnValue = testRead.getBlobColumn();
assertNotNull(columnValue);
assertEquals(byte[].class, columnValue.getClass());
assertTrue(Arrays.equals(blobValue, columnValue));
}
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testTIME2.
@Test
public void testTIME2() throws Exception {
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2003, 1, 1, 1, 20, 30);
Date timeValue = new Time(cal.getTime().getTime());
test.setTimeColumn(timeValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
Date columnValue = testRead.getTimeColumn();
assertNotNull(columnValue);
assertEquals(Date.class, columnValue.getClass());
assertEquals(timeValue.toString(), new Time(columnValue.getTime()).toString());
}
Aggregations