Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-01-2020 03:27 AM
I have created a pojo class and set up a structure how nodes should be created in neo4j. Using .save method which is inbuilt in neo4jRepository i am sending data using postman.
public Book addBook(Book book) {
return repository.save(book);
}
@PostMapping("/addBook")
public Classifier addingClassifier(@RequestBody Book book)) {
return bookService.addBook(book);
}
if i send same data using postman then neo4j is creating duplicate nodes. How to stop creating duplicate nodes.
04-01-2020 12:29 PM
use a unique constraint.
04-01-2020 09:51 PM
tried with unique constraint but it is of no use. It did not stop creating duplicate nodes.
04-02-2020 12:56 AM
By definition a unique constraint prevents duplication. I guess you're applying it not correctly.
04-02-2020 04:11 AM
No, I think I am using it correctly.
@NodeEntity
public class Book {
@Id
@GeneratedValue
private Long id;
@Index(unique = true)
private String name;
@Index(unique = true)
@Relationship(type = "Comprises_Of",direction = Relationship.OUTGOING)
private Set<Publishers> publishers;
}
04-02-2020 10:05 PM
what constraints do you actually have in the db: call db.constraints()
?
04-02-2020 10:17 PM
no constraints are applied to the fields.
04-05-2020 09:48 PM
@Index(Unique = true) is not working in the expected way. Please verify how to apply the unique constraint in spring boot code and let me know.
04-06-2020 02:31 AM
why not just fire a create constraint on ....
statement directly to the database and you're done?
All the sessions of the conference are now available online