use of org.neo4j.ogm.annotation.Id in project neo4j-ogm by neo4j.
the class EntityUtils method setIdentity.
public static void setIdentity(Object entity, Long identity, MetaData metaData) {
ClassInfo classInfo = metaData.classInfo(entity);
if (classInfo.hasIdentityField()) {
FieldInfo identityField = classInfo.identityField();
identityField.write(entity, identity);
} else if (identity == null) {
// Reset any generated field if the new value is null in case the generated values is not an internal id.
classInfo.fieldsInfo().fields().stream().filter(f -> f.getAnnotations().has(Id.class) && f.getAnnotations().has(GeneratedValue.class)).findFirst().ifPresent(generatedField -> generatedField.write(entity, null));
}
}
Aggregations