Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-24-2020 06:43 AM
I created some entities and tried to save them to the database. Some of them saved, some of them didn't. But no errors were thrown. I'm going to try to put together an example.
The Person
GOES_TO
a Place
. A Thing
is OWNED_BY
a Person
. I get a collection of people, and call saveAll(people)
and the Places are in the DB, but the People are not. Then I get a collection of Things from each person and the Things are saved in the DB, but still no People.
Here are some classes:
NodeEntity //put an @ here (new user limitation)
public class Person {
Id // put an @ here
private Long id;
private String name;
Relationship(type = "GOES_TO") // put an @ here
private Place place;
// ... getters and setters here
}
NodeEntity // put an @ here
public class Place {
Id // put an @ here
private Long id;
private String name;
Relationship(type = "IN") // put an @ here
private Country country; // note that this value is always null in this test
// ... getters and setters here
}
NodeEntity // put an @ here
public class Thing {
Id // put an @ here
private String thingId; // note the ID is different, not sure if that matters
private String name;
Relationship(type = "OWNED_BY") // put an @ here
private Person person;
// ... getters and setters here
}
Pretty simple right? I create standard Spring repositories for each entity like this:
public interface PersonRepository extends Neo4jRepository<Person, Long> {
}
Then I go to save some Person
objects. With a collection of Person
s, I see that the Place
s that they have inside them are being created in the database, but the Person
s are not. Then, I create a bunch of Thing
s, attaching the relevant Person
to them. This time the Thing
s are created, but still no Person
s are created. No error is being thrown, there just aren't any nodes.
P.S. this is a minimal example. I'm not 100% sure yet if it reproduces the error, but I'll work on an example of that. and update this post.
06-25-2020 09:24 AM
Yes a minimal example that runs and fails would be good, with the creation of the entities and how you run that transactionally too.
06-25-2020 09:35 AM
I managed to make it work. In summary, for some reason Neo4J was not liking that my IDs were Java Longs rather than Strings. When I changed the ID for the Person class to String, it started working. It wasn't throwing errors, and there weren't type issues, so I have no idea what was wrong.
All the sessions of the conference are now available online