【发布时间】:2022-01-18 11:59:18
【问题描述】:
我构建了一个 EMF 模型,该模型应规定允许存储在 Neo4J 数据库实例中的实体类型。
然后我想用 Neo4J OGM(版本 3.2.28)注释 EMF 模型类,以尽可能轻松地连接到 Neo4J。
看起来像这样:
BaseElement 和 ToolNameArtefact 是抽象的。 BaseElementImpl 中的字段uuid 用org.neo4j.ogm.annotation.Id 注释。
现在,当我尝试通过 Session#save() 存储 ConcreteArtefact 的实例时,我收到以下错误消息:
org.neo4j.ogm.exception.core.MappingException:实体 foo.bar.ConcreteArtefact@64d43929 的主 ID 字段为空(uuid:7745782f-2c61-4450-985a-8cf2986afa49,projectName:) 在 org.neo4j.ogm.context.MappingContext.nativeId(MappingContext.java:556) 在 org.neo4j.ogm.cypher.compiler.CypherContext.getIdentity(CypherContext.java:66) 在 org.neo4j.ogm.cypher.compiler.CypherContext.visitedNode(CypherContext.java:90) 在 org.neo4j.ogm.context.EntityGraphMapper.mapEntity(EntityGraphMapper.java:267) 在 org.neo4j.ogm.context.EntityGraphMapper.map(EntityGraphMapper.java:170) 在 org.neo4j.ogm.session.delegates.SaveDelegate.lambda$save$1(SaveDelegate.java:89) 在 java.util.Collections$SingletonList.forEach(Collections.java:4822) 在 org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:89) 在 org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:479)
虽然uuid字段是明确设置的。
其他解决方案建议
我的包名都是lower-case。
移动 NodeEntity annotations to the interfaces instead of the implementing classes 没有帮助。
有问题的类有一个no-arg constructor。
【问题讨论】:
标签: java neo4j-ogm eclipse-emf