use of org.apache.cayenne.unit.PostgresUnitDbAdapter in project cayenne by apache.
the class ReturnTypesMappingIT method testBLOB.
@Test
public void testBLOB() throws Exception {
assumeTrue("In postresql blob_column has OID type, but in JAVA it converts into long not into byte.", !(unitDbAdapter instanceof PostgresUnitDbAdapter));
if (unitDbAdapter.supportsLobs()) {
String columnName = "BLOB_COLUMN";
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();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap2")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
assertEquals(byte[].class, columnValue.getClass());
assertTrue(Arrays.equals(blobValue, (byte[]) columnValue));
}
}
Aggregations