cancel
Showing results for 
Search instead for 
Did you mean: 

Migration to RX

Michael_Herb
Node Link

I started the process of switching over to spring data neo4j rx. Right away, I noticed quite a few hurdles that we will need to overcome.

For starters, the missing support of @RelationshipEntity, @StartNode, @EndNode, @Index, @DateLong

We use RelationshipEntity a lot in our project, We have many relationship classes with @StartNode and @EndNode, and it is important to us to know which way the relationship -> points

Are there any suggestions as to how we can migrate. Here's an example of what I'm referring to:

@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(exclude = {"startRoute", "endRoute"}, callSuper = false)
@ToString(exclude = {"startRoute", "endRoute"})
//@CompositeIndex(value = {"Route_ID", "Capture_Id"}, unique = true)

@RelationshipEntity(type = "CARRIED_BY")
public class CarriedBy {
    @Id @GeneratedValue
    private Long graphId;

    @Index
    @Property(name = "Route_ID")
    private String id;

    @Property(name = "Route_IsAEnd")
    private boolean aEndRouteId;

    @Property(name = "Date_NetworkExtract")
    @DateLong
    private Date networkExtract;

    @Index
    @Property(name = "Capture_Id")
    private Long captureId;

    @StartNode
    private RouteEntity startRoute;

    @EndNode
    private RouteEntity endRoute;
}

Thanks.
1 ACCEPTED SOLUTION

I hope that somebody already reached out to you on a different channel but for having a documented answer here: https://jira.spring.io/browse/DATAGRAPH-1393
We are working on this.

View solution in original post

5 REPLIES 5

gerrit_meier
Neo4j
Neo4j

With the SDN 6.0 RC1 that has been released last Wednesday, there is a new API for mapping relationships with properties.

@RelationshipProperties
public class CarriedBy {

  @Property("Route_ID")
  private String id

// other properties

  @TargetNode
   private RouteEntity endRoute;
}

and in your RouteEntity something like:

@Relationship("CARRIED_BY")
private List<CarriedBy> carriedByRouteEntities;

will make SDN use those relationship properties classes.

For the raw conversion, you would need to define your own converter as described here: https://neo4j.github.io/sdn-rx/current/#conversions

Note: We are currently updating the documentation and examples for the new relationship properties and moving all to the official Spring Data reference docs.

Gerrit do you know when is going to be release?

It has already been released with SDN 6.0.0. To get some impression how it works and should be used I suggest to look into this test class https://github.com/spring-projects/spring-data-neo4j/blob/master/src/test/java/org/springframework/d...

Michael_Herb
Node Link

Thank you Gerrit.

Another snag in the migration we run into is this. We use converters for embedded objects as shown below:

    @Convert(RouteStateConverter.class)
    private RouteState routeState; 

And we wrote our own converters to go to/from the graph:

public class RouteStateConverter implements CompositeAttributeConverter<RouteState> {

    @Override
    public Map<String, ?> toGraphProperties(RouteState routeState) {
        // conversion code
    }

    @Override
    public RouteState toEntityAttribute(Map<String, ?> map) {
       // conversion code
    }

I hope that somebody already reached out to you on a different channel but for having a documented answer here: https://jira.spring.io/browse/DATAGRAPH-1393
We are working on this.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.