Added better error messages for entity instantiators.

This commit is contained in:
David Montag
2011-04-07 13:26:44 -07:00
parent 34b6abe9e1
commit b10ecc8c58
2 changed files with 11 additions and 7 deletions

View File

@@ -34,4 +34,8 @@ public class NodeEntityInstantiator extends AbstractConstructorEntityInstantiato
entity.setPersistentState(s);
}
@Override
protected String getFailingMessageForClass(Class<?> entityClass, Class<Node> stateClass) {
return entityClass.getSimpleName() + ": entity must have a no-arg constructor.";
}
}

View File

@@ -16,16 +16,9 @@
package org.springframework.data.graph.neo4j.support.relationship;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import org.neo4j.graphdb.Relationship;
import org.springframework.data.graph.core.RelationshipBacked;
import org.springframework.data.persistence.AbstractConstructorEntityInstantiator;
import org.springframework.data.persistence.EntityInstantiator;
import org.springframework.data.persistence.StateBackedCreator;
import sun.reflect.ReflectionFactory;
/**
@@ -40,6 +33,13 @@ public class RelationshipEntityInstantiator extends AbstractConstructorEntityIns
protected void setState(RelationshipBacked entity, Relationship relationship) {
entity.setPersistentState(relationship);
}
@Override
protected String getFailingMessageForClass(Class<?> entityClass, Class<Relationship> stateClass) {
return entityClass.getSimpleName() + ": entity must have a no-arg constructor.";
}
/*
protected <T extends RelationshipBacked> StateBackedCreator<T, Relationship> createInstantiator(Class<T> type, final Class<Relationship> stateType) {
StateBackedCreator<T,Relationship> creator = createWithoutConstructorInvocation(type,stateType);