diff --git a/src/main/java/org/springframework/persistence/graph/neo4j/Neo4jNodeBacking.aj b/src/main/java/org/springframework/persistence/graph/neo4j/Neo4jNodeBacking.aj index ab79dc804..c0aaaecdf 100644 --- a/src/main/java/org/springframework/persistence/graph/neo4j/Neo4jNodeBacking.aj +++ b/src/main/java/org/springframework/persistence/graph/neo4j/Neo4jNodeBacking.aj @@ -10,9 +10,12 @@ import org.neo4j.graphdb.Direction; import org.neo4j.graphdb.DynamicRelationshipType; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.NotInTransactionException; import org.neo4j.graphdb.RelationshipType; import org.neo4j.util.GraphDatabaseUtil; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.dao.InvalidDataAccessResourceUsageException; import org.springframework.persistence.graph.GraphEntity; import org.springframework.persistence.graph.Relationship; import org.springframework.persistence.support.AbstractTypeAnnotatingMixinFields; @@ -59,15 +62,19 @@ public aspect Neo4jNodeBacking extends AbstractTypeAnnotatingMixinFields Neo4J simple node property [" + propName + "] with value=[" + newVal + "]"); - return null; - } - - // Look for a relationship - if (isNeo4jRelationshipField(f)) { - RelationshipInfo relInfo = RelationshipInfo.forField(f); - graphEntityFieldSet(entity, (NodeBacked) newVal, relInfo); + try { + FieldSignature fieldSignature=(FieldSignature) thisJoinPoint.getSignature(); + Field f = fieldSignature.getField(); + // TODO fix arrays + if (f.getType().isPrimitive() || f.getType().equals(String.class)) { + String propName = getNeo4jPropertyName(f); + entity.getUnderlyingNode().setProperty(propName, newVal); + log.info("SET " + f + " -> Neo4J simple node property [" + propName + "] with value=[" + newVal + "]"); + return null; + } + + // Look for a relationship + if (isNeo4jRelationshipField(f)) { + RelationshipInfo relInfo = RelationshipInfo.forField(f); + graphEntityFieldSet(entity, (NodeBacked) newVal, relInfo); - log.info("SET " + f + " -> Neo4J relationship with value=[" + newVal + "]"); - return null; - } - else { - log.info("Ignored SET " + f + ": " + f.getType().getName() + " not primitive or GraphEntity"); - return proceed(entity, newVal); + log.info("SET " + f + " -> Neo4J relationship with value=[" + newVal + "]"); + return null; + } + else { + log.info("Ignored SET " + f + ": " + f.getType().getName() + " not primitive or GraphEntity"); + return proceed(entity, newVal); + } + } catch(NotInTransactionException e) { + throw new InvalidDataAccessResourceUsageException("Not in a Neo4j transaction.", e); } } @@ -179,10 +190,13 @@ public aspect Neo4jNodeBacking extends AbstractTypeAnnotatingMixinFields