* @throws InstantiationException
*/
private static void onViaEmbeddable(Attribute column, Object entity, Metamodel metamodel,
Map<String, Object> valueMap) throws InstantiationException, IllegalAccessException
{
EmbeddableType embeddable = metamodel.embeddable(((AbstractAttribute) column).getBindableJavaType());
Field embeddedField = (Field) column.getJavaMember();
Object embeddedDocumentObject = null;
if (column.isCollection())
{
Class embeddedObjectClass = PropertyAccessorHelper.getGenericClass(embeddedField);
embeddedDocumentObject = valueMap.get(((AbstractAttribute) column).getJPAColumnName());
if (embeddedDocumentObject != null)
{
Collection embeddedCollection = getCollectionFromDocumentList(metamodel,
(List<Map<String, Object>>) embeddedDocumentObject, embeddedField.getType(),
embeddedObjectClass, embeddable.getAttributes());
PropertyAccessorHelper.set(entity, embeddedField, embeddedCollection);
}
}
else
{
Object obj = PropertyAccessorHelper.getObject(entity, (Field) column.getJavaMember());
if (obj == null)
{
obj = ((AbstractAttribute) column).getBindableJavaType().newInstance();
}
embeddedDocumentObject = valueMap.get(((AbstractAttribute) column).getJPAColumnName());
if(embeddedDocumentObject != null)
PropertyAccessorHelper.set(
entity,
embeddedField,
getObjectFromDocument(metamodel, (Map<String, Object>) embeddedDocumentObject,
embeddable.getAttributes(), obj));
}
}