}
private Node createUniqueNode(Neo4jPersistentEntityImpl<?> persistentEntity, Object entity) {
Neo4jPersistentProperty uniqueProperty = persistentEntity.getUniqueProperty();
final Object value = getSerializedUniqueValue(entity, uniqueProperty);
if (value==null) throw new MappingException("Error creating "+uniqueProperty.getOwner().getName()+" with "+entity+" unique property "+uniqueProperty.getName()+" has null value");
final IndexInfo indexInfo = uniqueProperty.getIndexInfo();
if (indexInfo.isLabelBased()) {
return (indexInfo.isFailOnDuplicate())
? graphDatabase.createNode(map(uniqueProperty.getName(),value),persistentEntity.getAllLabels())
: graphDatabase.merge(indexInfo.getIndexName(), indexInfo.getIndexKey(), value, Collections.<String,Object>emptyMap(), persistentEntity.getAllLabels());