Relation relation)
{
EntityMetadata relationshipEntityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
relation.getMapKeyJoinClass());
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
relationshipEntityMetadata.getPersistenceUnit());
EntityType entityType = metaModel.entity(relationshipEntityMetadata.getEntityClazz());
// Iterate over, entity attributes
Set<Attribute> attributes = entityType.getSingularAttributes();
Object entity = null;
try
{
// entity =
// relationshipEntityMetadata.getEntityClazz().newInstance();
for (Attribute attribute : attributes)
{
Field field = (Field) attribute.getJavaMember();
String columnName = ((AbstractAttribute) attribute).getJPAColumnName();
// Set Entity level properties
if (metaModel.isEmbeddable(relationshipEntityMetadata.getIdAttribute().getBindableJavaType())
&& relationshipEntityMetadata.getIdAttribute().getJavaType().equals(field.getType()))
{
Object idValue = deserializeIdAttributeValue(relationshipEntityMetadata,
(String) relationship.getProperty(columnName));
if (idValue != null)
{
entity = initialize(relationshipEntityMetadata, entity);
PropertyAccessorHelper.set(entity, field, idValue);
}
}
else if (!attribute.isCollection() && !attribute.isAssociation()
&& !field.getType().equals(topLevelEntityMetadata.getEntityClazz())
&& !field.getType().equals(relation.getTargetEntity()))
{
Object value = relationship.getProperty(columnName, null);
if (value != null)
{
entity = initialize(relationshipEntityMetadata, entity);
PropertyAccessorHelper.set(entity, field, fromNeo4JObject(value, field));
}
}
}
if (entity != null
&& !metaModel.isEmbeddable(relationshipEntityMetadata.getIdAttribute().getBindableJavaType()))
{
Object rowKey = relationship.getProperty(((AbstractAttribute) relationshipEntityMetadata
.getIdAttribute()).getJPAColumnName());
if (rowKey != null)
{