neo4j RelationshipEntity not created












0















I'm having issues getting a neo4j RelationshipEntity persisted with Spring Boot. I'm using spring-boot-starter-data-neo4j (2.1.0.RELEASE), and the neo4j docker image tagged 3.4.9.



I have a simple NodeEntity, which contains a collection for the RelationshipEntity:



@NodeEntity
public class Book {
@Id
@GeneratedValue
private Long id;
private String name;

public Book() {}

public Book(String name) {
this.name = name;
}

@Relationship(type = "PURCHASED_WITH", direction = "OUTGOING")
private Set<BookPurchase> purchases = new HashSet<>();

// getters and setters follow
}


I have another NodeEntity, which also contains a collection for the relationship entity:



@NodeEntity
public class CreditCard {

@Id
@GeneratedValue
private Long id;
private String number;

@DateString(value = "yyyy-MM-dd")
private Date expiryDate;

public CreditCard() {}

public CreditCard(String number, Date expiryDate) {
this.number = number;
this.expiryDate = expiryDate;
}

@Relationship(type = "PURCHASED_WITH", direction = "INCOMING")
private Set<BookPurchase> purchases = new HashSet<BookPurchase>();

// getters and setters follow
}


I have the RelationshipEntity, which adds references to both NodeEntity classes in the constructor:



@RelationshipEntity(type = "PURCHASED_WITH")
public class BookPurchase {
@Id
@GeneratedValue
private long id;

@DateString("yyyy-MM-dd")
Date purchaseDate;

@StartNode
private Book book;

@EndNode
private CreditCard card;

public BookPurchase(){}

public BookPurchase(CreditCard card, Book book, Date purchaseDate) {
this.card = card;
this.book = book;
this.purchaseDate = purchaseDate;

this.card.getPurchases().add(this);
this.book.getPurchases().add(this);
}
// getters and setters follow
}


And finally I have the Spring controller tying everything together:



@RestController
public class ExamplesController {

@Autowired
CreditCardRepository creditCardRepository;

@PostMapping(value="/purchases")
public String createPurchases() {
CreditCard card = new CreditCard("11111", new GregorianCalendar(2018, Calendar.FEBRUARY, 12).getTime());

Book book1 = new Book("of mice and men");
BookPurchase purchase1 = new BookPurchase(card,book1,new GregorianCalendar(2018, Calendar.MARCH, 15).getTime());

creditCardRepository.save(card);
return "Successfully created entities";
}
}


Whenever I try to curl -X POST http://localhost:8080/purchases, I just see the following in the neo4j browser - the RelationshipEntity is not persisted, only the nodes.



Can anyone assist?



enter image description here










share|improve this question

























  • What does MATCH (n) OPTIONAL MATCH ()-[r]->() RETURN * return? Your shown query only returns nodes, and by default (depending on Neo4j version), auto relation linking in the browser is turned off (and you didn't say if you clicked the expand relationships button at the bottom of the circle of options)

    – Tezra
    Nov 15 '18 at 20:11











  • @Tezra thanks for your reply. I get the same result with the above query. Additionally, the browser highlights there are 'No relationships in database' under the 'Database information' view

    – dwaynetherock
    Nov 16 '18 at 1:35
















0















I'm having issues getting a neo4j RelationshipEntity persisted with Spring Boot. I'm using spring-boot-starter-data-neo4j (2.1.0.RELEASE), and the neo4j docker image tagged 3.4.9.



I have a simple NodeEntity, which contains a collection for the RelationshipEntity:



@NodeEntity
public class Book {
@Id
@GeneratedValue
private Long id;
private String name;

public Book() {}

public Book(String name) {
this.name = name;
}

@Relationship(type = "PURCHASED_WITH", direction = "OUTGOING")
private Set<BookPurchase> purchases = new HashSet<>();

// getters and setters follow
}


I have another NodeEntity, which also contains a collection for the relationship entity:



@NodeEntity
public class CreditCard {

@Id
@GeneratedValue
private Long id;
private String number;

@DateString(value = "yyyy-MM-dd")
private Date expiryDate;

public CreditCard() {}

public CreditCard(String number, Date expiryDate) {
this.number = number;
this.expiryDate = expiryDate;
}

@Relationship(type = "PURCHASED_WITH", direction = "INCOMING")
private Set<BookPurchase> purchases = new HashSet<BookPurchase>();

// getters and setters follow
}


I have the RelationshipEntity, which adds references to both NodeEntity classes in the constructor:



@RelationshipEntity(type = "PURCHASED_WITH")
public class BookPurchase {
@Id
@GeneratedValue
private long id;

@DateString("yyyy-MM-dd")
Date purchaseDate;

@StartNode
private Book book;

@EndNode
private CreditCard card;

public BookPurchase(){}

public BookPurchase(CreditCard card, Book book, Date purchaseDate) {
this.card = card;
this.book = book;
this.purchaseDate = purchaseDate;

this.card.getPurchases().add(this);
this.book.getPurchases().add(this);
}
// getters and setters follow
}


And finally I have the Spring controller tying everything together:



@RestController
public class ExamplesController {

@Autowired
CreditCardRepository creditCardRepository;

@PostMapping(value="/purchases")
public String createPurchases() {
CreditCard card = new CreditCard("11111", new GregorianCalendar(2018, Calendar.FEBRUARY, 12).getTime());

Book book1 = new Book("of mice and men");
BookPurchase purchase1 = new BookPurchase(card,book1,new GregorianCalendar(2018, Calendar.MARCH, 15).getTime());

creditCardRepository.save(card);
return "Successfully created entities";
}
}


Whenever I try to curl -X POST http://localhost:8080/purchases, I just see the following in the neo4j browser - the RelationshipEntity is not persisted, only the nodes.



Can anyone assist?



enter image description here










share|improve this question

























  • What does MATCH (n) OPTIONAL MATCH ()-[r]->() RETURN * return? Your shown query only returns nodes, and by default (depending on Neo4j version), auto relation linking in the browser is turned off (and you didn't say if you clicked the expand relationships button at the bottom of the circle of options)

    – Tezra
    Nov 15 '18 at 20:11











  • @Tezra thanks for your reply. I get the same result with the above query. Additionally, the browser highlights there are 'No relationships in database' under the 'Database information' view

    – dwaynetherock
    Nov 16 '18 at 1:35














0












0








0








I'm having issues getting a neo4j RelationshipEntity persisted with Spring Boot. I'm using spring-boot-starter-data-neo4j (2.1.0.RELEASE), and the neo4j docker image tagged 3.4.9.



I have a simple NodeEntity, which contains a collection for the RelationshipEntity:



@NodeEntity
public class Book {
@Id
@GeneratedValue
private Long id;
private String name;

public Book() {}

public Book(String name) {
this.name = name;
}

@Relationship(type = "PURCHASED_WITH", direction = "OUTGOING")
private Set<BookPurchase> purchases = new HashSet<>();

// getters and setters follow
}


I have another NodeEntity, which also contains a collection for the relationship entity:



@NodeEntity
public class CreditCard {

@Id
@GeneratedValue
private Long id;
private String number;

@DateString(value = "yyyy-MM-dd")
private Date expiryDate;

public CreditCard() {}

public CreditCard(String number, Date expiryDate) {
this.number = number;
this.expiryDate = expiryDate;
}

@Relationship(type = "PURCHASED_WITH", direction = "INCOMING")
private Set<BookPurchase> purchases = new HashSet<BookPurchase>();

// getters and setters follow
}


I have the RelationshipEntity, which adds references to both NodeEntity classes in the constructor:



@RelationshipEntity(type = "PURCHASED_WITH")
public class BookPurchase {
@Id
@GeneratedValue
private long id;

@DateString("yyyy-MM-dd")
Date purchaseDate;

@StartNode
private Book book;

@EndNode
private CreditCard card;

public BookPurchase(){}

public BookPurchase(CreditCard card, Book book, Date purchaseDate) {
this.card = card;
this.book = book;
this.purchaseDate = purchaseDate;

this.card.getPurchases().add(this);
this.book.getPurchases().add(this);
}
// getters and setters follow
}


And finally I have the Spring controller tying everything together:



@RestController
public class ExamplesController {

@Autowired
CreditCardRepository creditCardRepository;

@PostMapping(value="/purchases")
public String createPurchases() {
CreditCard card = new CreditCard("11111", new GregorianCalendar(2018, Calendar.FEBRUARY, 12).getTime());

Book book1 = new Book("of mice and men");
BookPurchase purchase1 = new BookPurchase(card,book1,new GregorianCalendar(2018, Calendar.MARCH, 15).getTime());

creditCardRepository.save(card);
return "Successfully created entities";
}
}


Whenever I try to curl -X POST http://localhost:8080/purchases, I just see the following in the neo4j browser - the RelationshipEntity is not persisted, only the nodes.



Can anyone assist?



enter image description here










share|improve this question
















I'm having issues getting a neo4j RelationshipEntity persisted with Spring Boot. I'm using spring-boot-starter-data-neo4j (2.1.0.RELEASE), and the neo4j docker image tagged 3.4.9.



I have a simple NodeEntity, which contains a collection for the RelationshipEntity:



@NodeEntity
public class Book {
@Id
@GeneratedValue
private Long id;
private String name;

public Book() {}

public Book(String name) {
this.name = name;
}

@Relationship(type = "PURCHASED_WITH", direction = "OUTGOING")
private Set<BookPurchase> purchases = new HashSet<>();

// getters and setters follow
}


I have another NodeEntity, which also contains a collection for the relationship entity:



@NodeEntity
public class CreditCard {

@Id
@GeneratedValue
private Long id;
private String number;

@DateString(value = "yyyy-MM-dd")
private Date expiryDate;

public CreditCard() {}

public CreditCard(String number, Date expiryDate) {
this.number = number;
this.expiryDate = expiryDate;
}

@Relationship(type = "PURCHASED_WITH", direction = "INCOMING")
private Set<BookPurchase> purchases = new HashSet<BookPurchase>();

// getters and setters follow
}


I have the RelationshipEntity, which adds references to both NodeEntity classes in the constructor:



@RelationshipEntity(type = "PURCHASED_WITH")
public class BookPurchase {
@Id
@GeneratedValue
private long id;

@DateString("yyyy-MM-dd")
Date purchaseDate;

@StartNode
private Book book;

@EndNode
private CreditCard card;

public BookPurchase(){}

public BookPurchase(CreditCard card, Book book, Date purchaseDate) {
this.card = card;
this.book = book;
this.purchaseDate = purchaseDate;

this.card.getPurchases().add(this);
this.book.getPurchases().add(this);
}
// getters and setters follow
}


And finally I have the Spring controller tying everything together:



@RestController
public class ExamplesController {

@Autowired
CreditCardRepository creditCardRepository;

@PostMapping(value="/purchases")
public String createPurchases() {
CreditCard card = new CreditCard("11111", new GregorianCalendar(2018, Calendar.FEBRUARY, 12).getTime());

Book book1 = new Book("of mice and men");
BookPurchase purchase1 = new BookPurchase(card,book1,new GregorianCalendar(2018, Calendar.MARCH, 15).getTime());

creditCardRepository.save(card);
return "Successfully created entities";
}
}


Whenever I try to curl -X POST http://localhost:8080/purchases, I just see the following in the neo4j browser - the RelationshipEntity is not persisted, only the nodes.



Can anyone assist?



enter image description here







spring-boot graph neo4j relationship






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 19:23







dwaynetherock

















asked Nov 15 '18 at 18:51









dwaynetherockdwaynetherock

133




133













  • What does MATCH (n) OPTIONAL MATCH ()-[r]->() RETURN * return? Your shown query only returns nodes, and by default (depending on Neo4j version), auto relation linking in the browser is turned off (and you didn't say if you clicked the expand relationships button at the bottom of the circle of options)

    – Tezra
    Nov 15 '18 at 20:11











  • @Tezra thanks for your reply. I get the same result with the above query. Additionally, the browser highlights there are 'No relationships in database' under the 'Database information' view

    – dwaynetherock
    Nov 16 '18 at 1:35



















  • What does MATCH (n) OPTIONAL MATCH ()-[r]->() RETURN * return? Your shown query only returns nodes, and by default (depending on Neo4j version), auto relation linking in the browser is turned off (and you didn't say if you clicked the expand relationships button at the bottom of the circle of options)

    – Tezra
    Nov 15 '18 at 20:11











  • @Tezra thanks for your reply. I get the same result with the above query. Additionally, the browser highlights there are 'No relationships in database' under the 'Database information' view

    – dwaynetherock
    Nov 16 '18 at 1:35

















What does MATCH (n) OPTIONAL MATCH ()-[r]->() RETURN * return? Your shown query only returns nodes, and by default (depending on Neo4j version), auto relation linking in the browser is turned off (and you didn't say if you clicked the expand relationships button at the bottom of the circle of options)

– Tezra
Nov 15 '18 at 20:11





What does MATCH (n) OPTIONAL MATCH ()-[r]->() RETURN * return? Your shown query only returns nodes, and by default (depending on Neo4j version), auto relation linking in the browser is turned off (and you didn't say if you clicked the expand relationships button at the bottom of the circle of options)

– Tezra
Nov 15 '18 at 20:11













@Tezra thanks for your reply. I get the same result with the above query. Additionally, the browser highlights there are 'No relationships in database' under the 'Database information' view

– dwaynetherock
Nov 16 '18 at 1:35





@Tezra thanks for your reply. I get the same result with the above query. Additionally, the browser highlights there are 'No relationships in database' under the 'Database information' view

– dwaynetherock
Nov 16 '18 at 1:35












1 Answer
1






active

oldest

votes


















0














Thanks to Gerrit Meier for answering this one. My RelationshipEntity was using the primitive long instead of the object/wrapper Long. Complete details here: https://community.neo4j.com/t/neo4j-relationshipentity-not-persisted/3039






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326136%2fneo4j-relationshipentity-not-created%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Thanks to Gerrit Meier for answering this one. My RelationshipEntity was using the primitive long instead of the object/wrapper Long. Complete details here: https://community.neo4j.com/t/neo4j-relationshipentity-not-persisted/3039






    share|improve this answer




























      0














      Thanks to Gerrit Meier for answering this one. My RelationshipEntity was using the primitive long instead of the object/wrapper Long. Complete details here: https://community.neo4j.com/t/neo4j-relationshipentity-not-persisted/3039






      share|improve this answer


























        0












        0








        0







        Thanks to Gerrit Meier for answering this one. My RelationshipEntity was using the primitive long instead of the object/wrapper Long. Complete details here: https://community.neo4j.com/t/neo4j-relationshipentity-not-persisted/3039






        share|improve this answer













        Thanks to Gerrit Meier for answering this one. My RelationshipEntity was using the primitive long instead of the object/wrapper Long. Complete details here: https://community.neo4j.com/t/neo4j-relationshipentity-not-persisted/3039







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 18 '18 at 4:40









        dwaynetherockdwaynetherock

        133




        133
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326136%2fneo4j-relationshipentity-not-created%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine