entity = newInstance();
try {
eem.putPartiallyConstructedEntity(key, entity);
for (Attribute<? super X, ?> a : getAttributes()) {
ErraiAttribute<? super X, ?> attr = (ErraiAttribute<? super X, ?>) a;
JSONValue attrJsonValue = jsonValue.isObject().get(attr.getName());
switch (attr.getPersistentAttributeType()) {
case ELEMENT_COLLECTION:
case EMBEDDED:
case BASIC:
parseInlineJson(entity, attr, attrJsonValue, eem);
break;
case MANY_TO_MANY:
case MANY_TO_ONE:
case ONE_TO_MANY:
case ONE_TO_ONE:
if (attr instanceof ErraiSingularAttribute) {
parseSingularJsonReference(entity, (ErraiSingularAttribute<? super X, ?>) attr, attrJsonValue, eem);
}
else if (attr instanceof ErraiPluralAttribute) {
parsePluralJsonReference(entity, (ErraiPluralAttribute<? super X, ?, ?>) attr, attrJsonValue.isArray(), eem);
}
else {
throw new PersistenceException("Unknown attribute type " + attr);
}
}