Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eager or lazy load in Spring data neo4j 4

I'm trying to use spring data neo4j in my project here's a simple entity:

@NodeEntity
public class Actor{

@GraphId
private Long id;

@Property(name="name")
private String fullName;

@Relationship(type="ACTED_IN", direction=Relationship.OUTGOING)
private List<Movie> filmography = new ArrayList<Movie>();
}

I wonder if there is a way to tell spring to use lazy load on entity relationships?

like image 773
Yuriy Dubyna Avatar asked Nov 24 '25 10:11

Yuriy Dubyna


1 Answers

There isn't a concept of lazy loading in SDN 4. To avoid loading all related entities, you can load the entity to depth 0- this will load only properties of the entity but no relationships.

Loading the entity to depth 1 (the default), will load properties of the node, related nodes and their properties.

Note however that at this time, you cannot load certain relationships and exclude others. There's a feature request open for this, feel free to +1

like image 166
Luanne Avatar answered Nov 26 '25 01:11

Luanne