Hi all,
I am having some trouble trying to migrate from SDN 4.1 to 6.0.x. We heavily use @RelationshipEntity
with @StartNode
and @EndNode
, from the OGM. I have seem in the documentation and other posts that the way to go is @RelationshipProterties
and @TargetNode
.
I am going to put some code here and any help, advice will be extremely welcome!
OGM Implementation
@RelationshipEntity(type = "hasCandidate")
public class HasCandidate implements Comparable<HasCandidate> {
@Id private Long id;
@StartNode private EntitySet entitySet;
@EndNode private PhysicalEntity physicalEntity;
private Integer stoichiometry = 1;
private int order;
// getter and setters
Now, the class that takes the Relationship, still using the OGM implementation
@NodeEntity
public class CandidateSet extends EntitySet {
@Relationship(type = "hasCandidate")
private SortedSet<HasCandidate> hasCandidate;
// any other code
}
Our modelling comes from a legacy code and can't be changed. So, a CandidateSet
extends EntitySet
and an EntitySet
extends PhysicalEntity
.
Now the way I am thinking with the new approach @RelationshipProperties
@RelationshipProperties
public class HasCandidate implements Comparable<HasCandidate> {
@Id private Long id;
@TargetNode private PhysicalEntity physicalEntity;
private Integer stoichiometry = 1;
private int order;
... and the class that uses HasCandidate
relationship
@Node
public class CandidateSet extends EntitySet {
@Relationship(type = "hasCandidate")
private SortedSet<HasCandidate> hasCandidate;
and also the @TargetNode
class has an attribute for this Relationship in the Physical Entity
class.
@Node
public class PhysicalEntity extends DatabaseObject {
...
@Relationship(type = "hasComponent", direction = Relationship.Direction.INCOMING)
private SortedSet<HasCandidate> hasCandidate;
I am not so sure if this is the correct way, taking into account that PhysicalEntity
is the @TargetNode
and it also the superclass for CandidateSet
and EntitySet
( as @StartNode
in the previous implementation.
According to the example I need to add Relationship.Direction.INCOMING
Questions:
- Is the code above correct ?
- How do I set the name as I was doing before ?
@RelationshipEntity(type = "hasCandidate")
Unfortunately, due to all the updates and refactoring I am doing at the moment, I can't test it, but I was wondering if this is correct and make sense.
Thanks everyone, Cheers.