I am using Spring-data to access a Neo4j database via REST.
One of my entities looks similar to the following one:
@NodeEntity
@TypeAlias("org.example.Foo")
public class Foo {
@GraphId
private Long nodeId;
//...
@RelatedTo(type="HAS_BAR", direction=Direction.OUTGOING)
private Set<Bar> bars;
//...
}
A typical Foo
might have anywhere from 0-1000 Bar
s. Most of the time, those Bar
s are not needed when loading a Foo
so I thought I should by fine by not adding a @Fetch
annotation and thus avoiding to eager-load the Bar
s.
However, when now loading a Foo
using the generated repository methods, the Bar
s are loaded - at least partially (only their nodeId properties).
Is there any way to avoid this? Performance suffers quite much from this behavior.
I really would like to be able to use lazy-loading like shown in https://stackoverflow.com/a/16159051/232175 for the collection itself.