use of org.apache.cayenne.DataRow in project cayenne by apache.
the class EntityRowReader method readRow.
@Override
public DataRow readRow(ResultSet resultSet) {
try {
DataRow row = new DataRow(mapCapacity);
int len = converters.length;
for (int i = 0; i < len; i++) {
// note: jdbc column indexes start from 1, not 0 as in arrays
Object val = converters[i].materializeObject(resultSet, startIndex + i + 1, types[i]);
row.put(labels[i], val);
}
postprocessRow(resultSet, row);
return row;
} catch (CayenneRuntimeException cex) {
// rethrow unmodified
throw cex;
} catch (Exception otherex) {
throw new CayenneRuntimeException("Exception materializing id column.", Util.unwindException(otherex));
}
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class IdRowReader method readIdMap.
@SuppressWarnings("unchecked")
private T readIdMap(ResultSet resultSet) throws Exception {
DataRow idRow = new DataRow(2);
idRow.setEntityName(entityName);
for (int index : pkIndices) {
// dereference column index
// note: jdbc column indexes start from 1, not 0 as in arrays
Object val = converters[index].materializeObject(resultSet, index + 1, types[index]);
idRow.put(labels[index], val);
}
if (postProcessor != null) {
postProcessor.postprocessRow(resultSet, idRow);
}
return (T) idRow;
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class EmbeddableRowReader method readRow.
@Override
public DataRow readRow(ResultSet resultSet) {
try {
DataRow row = new DataRow(mapCapacity);
int len = converters.length;
for (int i = 0; i < len; i++) {
// note: jdbc column indexes start from 1, not 0 as in arrays
Object val = converters[i].materializeObject(resultSet, startIndex + i + 1, types[i]);
row.put(labels[i], val);
}
return row;
} catch (CayenneRuntimeException cex) {
// rethrow unmodified
throw cex;
} catch (Exception otherex) {
throw new CayenneRuntimeException("Exception materializing column.", Util.unwindException(otherex));
}
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class FullRowReader method readRow.
@Override
public DataRow readRow(ResultSet resultSet) {
try {
DataRow dataRow = new DataRow(mapCapacity);
int resultWidth = labels.length;
// process result row columns,
for (int i = 0; i < resultWidth; i++) {
// note: jdbc column indexes start from 1, not 0 unlike
// everywhere else
Object val = converters[i].materializeObject(resultSet, i + 1, types[i]);
dataRow.put(labels[i], val);
}
postprocessRow(resultSet, dataRow);
return dataRow;
} catch (CayenneRuntimeException cex) {
// rethrow unmodified
throw cex;
} catch (Exception otherex) {
throw new CayenneRuntimeException("Exception materializing column.", Util.unwindException(otherex));
}
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class JDBCResultIteratorTest method testNextDataRow.
@Test
public void testNextDataRow() throws Exception {
Connection c = new MockConnection();
Statement s = new MockStatement(c);
MockResultSet rs = new MockResultSet("rs");
rs.addColumn("a", new Object[] { "1", "2", "3" });
RowDescriptor descriptor = new RowDescriptorBuilder().setResultSet(rs).getDescriptor(new ExtendedTypeMap());
RowReader<?> rowReader = new DefaultRowReaderFactory().rowReader(descriptor, new MockQueryMetadata(), mock(DbAdapter.class), Collections.<ObjAttribute, ColumnDescriptor>emptyMap());
JDBCResultIterator it = new JDBCResultIterator(s, rs, rowReader);
DataRow row = (DataRow) it.nextRow();
assertNotNull(row);
assertEquals(1, row.size());
assertEquals("1", row.get("a"));
}
Aggregations