显然,这是一个常见的例外,但是,这里提出的所有问题似乎都与CSV
有关,因此,为什么要提出这个问题。
我有一个domain
对象,它使用uuid
作为唯一ID,并声明为Follow
@NodeEntity(label = "TNODE")
public class TestNode {
@Id @GeneratedValue(strategy = UuidStrategy.class)
@Convert(UuidStringConverter.class)
private UUID uuid;
private String name;
@Relationship(type = "TEST_REL_IS", direction = Relationship.OUTGOING) private TestNodeTarget testTarget;
public TestNode() {}
public TestNode(String name, TestNodeTarget target) {
this.name = name;
this.testTarget = target;
}
//getters and setters
}
TestNodeTarget
如下
@NodeEntity(label = "TNODE_TARGET")
public class TestNodeTarget {
private Long id;
private String name;
public TestNodeTarget() {}
public TestNodeTarget(String name) {
this.name = name;
}
//getters and setters
}
我正在将Spring Boot 2.0.3.RELEASE
与sprng-boot-data-neo4j
起动器一起使用,该起动器会拉低neo4j-ogm-core-3.1.0
,neo4j-ogm-bolt-driver-3.1.0
,neo4j-ogm-api-3.1.0
和神秘的neo4j-java-driver-1.5
。
我正在使用Neo4j OGM SessionFactory
来构建自己的通用DAO层,而不是使用Spring Data Repository来限制我的访问权限
我能够执行CREATE
,READ
和DELETE
操作。遵循以下假设的PUT
操作
tn:TestNode
,t1:TestNodeTarget
和t2:TestNodeTarget
tn
节点与t1
节点有关系tn
个节点,t1 & t2
个节点tn
的节点关系从t2
更改为t1
session.save
例外是
Caused by: org.neo4j.driver.v1.exceptions.ClientException: Cannot merge node using null property value for uuid
at org.neo4j.driver.internal.util.ErrorUtil.newNeo4jError(ErrorUtil.java:62)
at org.neo4j.driver.internal.async.inbound.InboundMessageDispatcher.handleFailureMessage(InboundMessageDispatcher.java:137)
at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.unpackFailureMessage(PackStreamMessageFormatV1.java:432)
at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.read(PackStreamMessageFormatV1.java:396)
at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:83)
at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:35)
at org.neo4j.driver.internal.shaded.io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)
at org.neo4j.driver.internal.async.inbound.MessageDecoder.channelRead(MessageDecoder.java:40)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at org.neo4j.driver.internal.shaded.io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1336)
at org.neo4j.driver.internal.shaded.io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1127)
at org.neo4j.driver.internal.shaded.io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1162)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935)
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
Caused by: org.neo4j.driver.v1.exceptions.ClientException: Cannot merge node using null property value for uuid
消息的根本原因是什么?节点uuid
的值不为null。 bolt-driver
和neo4j-java-driver
如何相互通信?我很惊讶地看到neo4j-java-driver
。Neo4j OGM
来代替Spring Data的Repository
,那么我可以抛弃spring-boot-starter-data-neo4j
吗?如果是,@Transactional
和事务管理会怎样? 答案 0 :(得分:1)
使用带有UUID
注释的@Id
字段不能代替private Long id
字段(或者是?)。将id
字段添加到类中,该异常消失。
我等不及了,决定自己调试此问题并分享我的发现
首先,PUT
操作(无private Long id
字段)无一例外地工作,但是未能删除旧的关系,基于此Github issue,我将这些操作包装在{{1 }},我得到了例外。一些进步。
在@Transactional
上下文中,上述方法可以正常工作。换句话说,我可以ORM
来自retrieve
带注释的服务层的实体,在@Transactional
层中进行必要的更改,然后使用另一种服务层方法non-transactional
用persist
注释。对于@Transactional
,您必须在同一事务层中全部完成。哼!
如上面的问题所示,OGM
实体按如下方式使用TestNode
UUID
我必须更新@Id @GeneratedValue(strategy = UuidStrategy.class)
@Convert(UuidStringConverter.class)
private UUID uuid;
类以包含
TestNode
然后,private Long id;
操作将按预期工作,并且旧的关系将被删除。
为什么缺少PUT
只会在更新期间导致异常?为什么在您private Long id;
,retrieve
或delete
实体时不这样做?