Using SDN 6 I have classes like
abstract base class with auditing:
public abstract class Node {
@Id @GeneratedValue @Getter private Long id;
@Version @Getter private Long version;
@CreatedDate @Getter private LocalDateTime created;
@CreatedBy @Getter private Long createdBy;
@LastModifiedDate @Getter private LocalDateTime modified;
@LastModifiedBy @Getter private Long modifiedBy;
...
}
all other @Node classes (Order, User, Coupon) are derived from that like
@Node
@Getter
@Setter
public class Order extends Node {
...
@Relationship("BY") private User user;
@Relationship("COUPON") private Coupon coupon;
...
}
and this sort of existing dataset:
(o:Order)-[:BY]->(:User)<-[:AFFILIATE]-(c:Coupon)
i.e. I already have an Order by a User which also is the affiliate associated with a Coupon.
Now when that same user redeems such a coupon like
o.setCoupon(c);
orderRepo.save(o);
which should create an additional relationship like
(o:Order)-[:BY]->(:User)<-[:AFFILIATE]-(c:Coupon)
\--------[:COUPON]---------------->/
all I ever get is an exception with the mesage
An entity with the required version does not exist.
It seems like saving the Order traverses to the User attached to the order (via BY) and increments the version nr AND also to the newly attached coupon which is in turn attached to the same User (via AFFILIATE) and that causes version conflicts .... or something like that. Or maybe the problem actually lies in the version of the Order since through the coupon there is now a connection back onto itself?
Someone please fix this or tell me what I am doing wrong because I guess for now I will have to remove auditing completely :(