public <R> R copyPropertiesFrom(
     final BeanWrapper<Neo4jPersistentEntity<R>, R> wrapper,
     S source,
     Neo4jPersistentEntity<R> persistentEntity,
     final MappingPolicy mappingPolicy,
     final Neo4jTemplate template) {
   final R entity = wrapper.getBean();
   final EntityState<S> entityState = entityStateFactory.getEntityState(entity, false, template);
   entityState.setPersistentState(source);
   persistentEntity.doWithProperties(
       new PropertyHandler<Neo4jPersistentProperty>() {
         @Override
         public void doWithPersistentProperty(Neo4jPersistentProperty property) {
           copyEntityStatePropertyValue(
               property, entityState, wrapper, property.getMappingPolicy()); // TODO intelligent
           // mappingPolicy.combineWith(property.getMappingPolicy())
         }
       });
   persistentEntity.doWithAssociations(
       new AssociationHandler<Neo4jPersistentProperty>() {
         @Override
         public void doWithAssociation(Association<Neo4jPersistentProperty> association) {
           final Neo4jPersistentProperty property = association.getInverse();
           copyEntityStatePropertyValue(
               property, entityState, wrapper, property.getMappingPolicy()); // TODO intelligent
           // mappingPolicy.combineWith(property.getMappingPolicy())
         }
       });
   return entity;
 }
 public <R> void copyPropertiesTo(
     final BeanWrapper<Neo4jPersistentEntity<R>, R> wrapper,
     S target,
     Neo4jPersistentEntity<R> persistentEntity,
     MappingPolicy mappingPolicy,
     final Neo4jTemplate template) {
   final Transaction tx = template.getGraphDatabase().beginTx();
   try {
     final EntityState<S> entityState =
         entityStateFactory.getEntityState(wrapper.getBean(), false, template);
     entityState.setPersistentState(target);
     entityState.persist();
     // todo take mapping policies for attributes into account
     persistentEntity.doWithProperties(
         new PropertyHandler<Neo4jPersistentProperty>() {
           @Override
           public void doWithPersistentProperty(Neo4jPersistentProperty property) {
             setEntityStateValue(property, entityState, wrapper, property.getMappingPolicy());
           }
         });
     // todo take mapping policies for relationships into account
     persistentEntity.doWithAssociations(
         new AssociationHandler<Neo4jPersistentProperty>() {
           @Override
           public void doWithAssociation(Association<Neo4jPersistentProperty> association) {
             final Neo4jPersistentProperty property = association.getInverse();
             setEntityStateValue(property, entityState, wrapper, property.getMappingPolicy());
           }
         });
     tx.success();
   } catch (Throwable t) {
     tx.failure();
     if (t instanceof Error) throw (Error) t;
     if (t instanceof RuntimeException) throw (RuntimeException) t;
     throw new org.springframework.data.neo4j.core.UncategorizedGraphStoreException(
         "Error copying properties from " + persistentEntity + " to " + target, t);
   } finally {
     tx.close();
   }
 }
 public <T> Result<T> findAll(Neo4jPersistentEntity entity) {
   String label = entity.getTypeAlias().toString();
   String query = findByLabelQuery(label);
   return cypher.query(query, null).<T>to(entity.getType());
 }
 private Neo4jPersistentProperty property(Field field) {
   return persistentEntity.getPersistentProperty(field.getName());
 }