while (rowsIter.hasNext())
{
relationMap = new HashMap<String, Object>();
entity = initializeEntity(key, entityMetadata);
Row row = rowsIter.next();
List<String> fields = row.getTable().getFields();
FieldDef fieldMetadata = null;
FieldValue value = null;
String idColumnName = ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName();
if (/* eligibleToFetch(columnsToSelect, idColumnName) && */!metaModel.isEmbeddable(entityMetadata
.getIdAttribute().getBindableJavaType()))
{
populateId(entityMetadata, schemaTable, entity, row);
}
else
{
onEmbeddableId(entityMetadata, metaModel, schemaTable, entity, row);
}
Iterator<String> fieldIter = fields.iterator();
Set<Attribute> attributes = entityType.getAttributes();
for (Attribute attribute : attributes)
{
String jpaColumnName = ((AbstractAttribute) attribute).getJPAColumnName();
if (eligibleToFetch(columnsToSelect, jpaColumnName)
&& !attribute.getName().equals(entityMetadata.getIdAttribute().getName()))
{
if (metaModel.isEmbeddable(((AbstractAttribute) attribute).getBindableJavaType()))
{
// readEmbeddable(value, columnsToSelect,
// entityMetadata, metaModel, schemaTable, value,
// attribute);
EmbeddableType embeddableId = metaModel.embeddable(((AbstractAttribute) attribute)
.getBindableJavaType());
Set<Attribute> embeddedAttributes = embeddableId.getAttributes();
Object embeddedObject = ((AbstractAttribute) attribute).getBindableJavaType().newInstance();
for (Attribute embeddedAttrib : embeddedAttributes)
{
String embeddedColumnName = ((AbstractAttribute) embeddedAttrib).getJPAColumnName();
fieldMetadata = schemaTable.getField(embeddedColumnName);
value = row.get(embeddedColumnName);
NoSqlDBUtils.get(fieldMetadata, value, embeddedObject,
(Field) embeddedAttrib.getJavaMember());
}
PropertyAccessorHelper.set(entity, (Field) attribute.getJavaMember(), embeddedObject);
}
else
{
fieldMetadata = schemaTable.getField(jpaColumnName);
value = row.get(jpaColumnName);
if (!attribute.isAssociation() && value != null)
{
NoSqlDBUtils.get(fieldMetadata, value, entity, (Field) attribute.getJavaMember());
}