Spring Data Neo4j 4.2.0.BUILD-SNAPSHOT OGM 2.1.0-SNAPSHOT NullPointerException

На последних Spring Data Neo4j 4.2.0.BUILD-SNAPSHOT и OGM 2.1.0-SNAPSHOT мои тесты провалились со следующим NPE(несколько дней назад все работало нормально и ни одна строчка моего кода не была изменена):

java.lang.NullPointerException
    at org.neo4j.ogm.entity.io.EntityAccessManager.getRelationalReaders(EntityAccessManager.java:355)
    at org.neo4j.ogm.context.EntityGraphMapper.bothWayMappingRequired(EntityGraphMapper.java:893)
    at org.neo4j.ogm.context.EntityGraphMapper.mapEntityReferences(EntityGraphMapper.java:396)
    at org.neo4j.ogm.context.EntityGraphMapper.mapEntity(EntityGraphMapper.java:230)
    at org.neo4j.ogm.context.EntityGraphMapper.map(EntityGraphMapper.java:134)
    at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:83)
    at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:44)
    at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:419)
    at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.data.neo4j.transaction.SharedSessionCreator$SharedSessionInvocationHandler.invoke(SharedSessionCreator.java:133)
    at com.sun.proxy.$Proxy115.save(Unknown Source)
    at org.springframework.data.neo4j.repository.support.SimpleGraphRepository.save(SimpleGraphRepository.java:70)
    at sun.reflect.GeneratedMethodAccessor60.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy128.save(Unknown Source)
    at com.decisionwanted.domain.dao.decision.CharacteristicOptionDaoImpl.createOrUpdate(CharacteristicOptionDaoImpl.java:44)
    at com.decisionwanted.domain.dao.decision.CharacteristicOptionDaoImpl.create(CharacteristicOptionDaoImpl.java:24)
    at com.decisionwanted.domain.DecisionCharacteristicTest.testDecisionCharacteristicOptions(DecisionCharacteristicTest.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Мой код:

@NodeEntity
public class Characteristic extends Authorable {

    public final static String NODE_NAME = "Characteristic";

    private final static String CONTAINS = "CONTAINS";
    private final static String DEFINED_BY = "DEFINED_BY";

    private String name;

    private String description;

    private Type type;

    private Mode mode;

    private boolean sortable;

    @Relationship(type = CONTAINS, direction = Relationship.OUTGOING)
    private Set<CharacteristicOption> options = new HashSet<>();

    @Relationship(type = CONTAINS, direction = Relationship.INCOMING)
    private CharacteristicGroup group;

    @Relationship(type = DEFINED_BY, direction = Relationship.OUTGOING)
    private Decision owner;

    public Characteristic() {
    }

    public Characteristic(String name, String description, Type type, Mode mode, Decision owner, User author) {
        this.name = name;
        this.description = description;
        this.type = type;
        this.mode = mode;
        this.owner = owner;
        setAuthor(author);
    }

    public Characteristic(String name, String description, Type type, Mode mode, Decision owner, User author, CharacteristicGroup group) {
        this(name, description, type, mode, owner, author);
        this.group = group;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public Mode getMode() {
        return mode;
    }

    public void setMode(Mode mode) {
        this.mode = mode;
    }

    public boolean isSortable() {
        return sortable;
    }

    public void setSortable(boolean sortable) {
        this.sortable = sortable;
    }

    public Set<CharacteristicOption> getOptions() {
        return options;
    }

    public void setOptions(Set<CharacteristicOption> options) {
        this.options = options;
    }

    public boolean addOption(CharacteristicOption option) {
        return options.add(option);
    }

    public CharacteristicGroup getGroup() {
        return group;
    }

    public void setGroup(CharacteristicGroup group) {
        this.group = group;
    }

    public Decision getOwner() {
        return owner;
    }

    public void setOwner(Decision owner) {
        this.owner = owner;
    }

    public static enum Type {

        //@formatter:off
        BOOLEAN("Boolean"),
        INTEGER("Integer"),
        STRING("String");
        //@formatter:on

        private final String name;

        Type(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

    }

    public static enum Mode {

        //@formatter:off
        CHECKBOX("CheckBox"),
        SLIDER("Slider"),
        SELECTBOX("SelectBox"),
        RADIOGROUP("String");
        //@formatter:on

        private final String name;

        Mode(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

    }
}

@NodeEntity
public class CharacteristicOption extends BaseEntity {

    private final static String CONTAINS = "CONTAINS";

    private String name;

    private String description;

    private Object value;

    @Relationship(type = CONTAINS, direction = Relationship.INCOMING)
    private Characteristic characteristic;

    public CharacteristicOption() {
    }

    public CharacteristicOption(String name, String description, Object value, Characteristic characteristic) {
        this.name = name;
        this.description = description;
        this.value = value;
        this.characteristic = characteristic;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public Characteristic getCharacteristic() {
        return characteristic;
    }

    public void setCharacteristic(Characteristic characteristic) {
        this.characteristic = characteristic;
    }

}

@Override
public CharacteristicOption createOrUpdate(CharacteristicOption characteristicOption) {
    auditing(characteristicOption);

    return characteristicOptionRepository.save(characteristicOption);
}

В чем может быть причина этой проблемы и как ее исправить?


person alexanoid    schedule 08.10.2016    source источник
comment
можете ли вы проверить, что вы находитесь на последнем снимке как OGM, так и SDN? Вчера у нас был перерыв в сборке, и вы можете использовать эту версию. Возможно, вам просто нужно принудительно обновить последний снимок. Проверьте репозитории моментальных снимков spring и neo4j maven для получения последних версий. если вы все еще получаете сообщение об ошибке, пожалуйста, откройте проблему github.   -  person digx1    schedule 08.10.2016
comment
@digx1 спасибо за ответ. Не повезло .. Я обновил репо с тем же результатом, поэтому я создал следующую проблему github github.com/neo4j/neo4j-ogm/issues/254   -  person alexanoid    schedule 08.10.2016


Ответы (1)


Ваш класс CharacteristicOption объявляет поле:

private Object value;

Недавняя фиксация в 2.1.0-SNAPSHOT исключила ссылки Object и Object[] в качестве сохраняемых свойств. В результате OGM попытался отобразить свойство value через отношение, а не как простой атрибут узла.

Это было исправлено в последней сборке моментального снимка.

person Vince    schedule 17.10.2016