/** * Populates and iterates through a {@link Row} using {@link ColumnDefinitions} provided by the * driver. * * @param row * @return */ public T get(Row row) { // Entity and its associated id object T entity = null; Object idObj = null; try { entity = entityClass.newInstance(); idObj = null; ColumnMapping idcolmap = null; // Note that this early invocation means that // you can't populate on #setId in your java bean method if (embedded != null) { idObj = embedded.field.getType().newInstance(); embedded.set(entity, idObj); } else { idObj = idMapping.field.getType().newInstance(); idMapping.set(entity, idObj); } } catch (InstantiationException | IllegalAccessException e) { throw new IllegalAccessError( "A configuration exception has occurred in creating entity: " + entityClass); } ColumnDefinitions metaData = row.getColumnDefinitions(); List<Definition> defList = metaData.asList(); for (Definition def : defList) { ColumnMapping mapping = colsToFields.get(def.getName()); if (mapping == null) { // it could be an id column if (idMapping != null && def.getName().equals(idMapping.name)) { idMapping.set(entity, getValue(row, idMapping, def)); continue; } // else: need to find it, possible point of refactor ColumnMapping nembed = null; if (embedded != null) nembed = embedded.get(def.getName()); if (nembed != null) nembed.set(idObj, getValue(row, nembed, def)); continue; } Object value = getValue(row, mapping, def); // set it if (value != null) mapping.set(entity, value); } return entity; }