I have an entity "Track" that has a relationship to a list of track objects (TrackObject). I have a list of tracks that I want to save to the Neo4j database and each Track has a list of TrackObjects. Every track gets saved perfectly but only the first TrackObject get saved. Is there a way to save everything directly? Here is the Track:
@NodeEntity (label="Track")
public class Track {
@Id
@GeneratedValue
private Long id;
Integer number;
String name;
@Relationship (type = "IS_IN", direction=Relationship.INCOMING)
List<TrackObject> objectList;
I get my list of Tracks and iterate it:
for (Track track : tracks) {
trackService.saveTrack(track);
for (TrackObject tobj : track.getObjectList()) {
trackService.saveTrackObject(tobj);
I also tried with "saveAll" and Iterable and it works for the tracks but not for the list of track objects.
Iterable<Track> tracks = newImport.getTracks();
trackService.saveTracks(tracks);
What am I doing wrong? Thank you for your answers.