当前位置: 首页 > 知识库问答 >
问题:

Spring数据Neo4j 4.2。0.2.1版本。0-SNAPSHOT NullPointerException

司空玮
2023-03-14

关于最新的Spring Data Neo4j 4.2.0。BUILD-SNAPSHOTOGM 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);
}

这个问题的原因是什么?如何解决它?

共有1个答案

哈烨熠
2023-03-14

您的CharacteristicOption类声明了一个字段:

私有对象值

最近对2.1的promise。0-快照排除了对象对象[]引用作为持久属性。因此,OGM试图通过关系映射属性,而不是作为简单的节点属性。

这已在最新的快照生成中更正。

 类似资料:
  • 我有与Spring data neo4j一起工作的Spring服务,我决定将Spring data neo4j从2.2更新到当前版本-3.1.4。释放。所以第一次我更新了neo4j,项目失败了,我更新了Spring版本,不同的版本有不同的例外。这个服务包括在我的前端,我叫它是从网络。所以我不知道什么是最佳配置???配置与maven。这里有pom.xml Spring配置文件 所以每次加载db例外,

  • 我正在用Spring Cloud数据流实现一个流管道。 我的问题是,我手动配置了服务器中的管道(例如),如果我重置该服务器,它将丢失(以Amazon EC2实例为例,该实例可以硬重置)。

  • 原因:java。lang.UnsupportedClassVersionError:org/bson/codecs/record/recordcodeceprovider由最新版本的Java运行时(类文件版本61.0)编译,该版本的Java运行时仅识别Java中高达59.0的类文件版本。基本/java。lang.ClassLoader。defineClass1(本机方法)~[na:na] 在pom

  • 当我试图更新我的项目JAR以与新版本的neo4j服务器兼容时,我正在使用neo4j 2.1.2服务器我遇到了问题。 这是porm.xml中使用的旧版本配置 这是新的: 但是当我试图编译我的应用程序时,我得到了这样的跟踪跟踪:

  • 我使用的是spring boot 1.5.7。发布,spring data elasticsearch 3.0.2。释放和弹性搜索5.6.3。然而,当使用maven进行构建时,它似乎在加载elasticsearch 2.4.6。当我试图通过pom文件强制elasticsearch 5.6.3时,我收到运行时异常,该异常显示缺少运行时依赖项。有什么想法吗?

  • 本文向大家介绍SqlServer高版本数据备份还原到低版本,包括了SqlServer高版本数据备份还原到低版本的使用技巧和注意事项,需要的朋友参考一下 最近遇见一个问题:   想要将Sqlserver高版本备份的数据还原到低版本SqlServer上去,但是这在SqlServer中是没法直接还原数据库的,所以经过一系列的请教总结出来一下可用方法。 首先、你得在电脑上装有你将要操作的高版本以及低版本的