Note that there are some explanatory texts on larger screens.

plurals
  1. POcan't save @RelationshipEntity
    primarykey
    data
    text
    <p>I'm try to save some @RelationshipEntity: I've questionnaires, each of them related to some questions. First I tried like follow:</p> <pre><code>@RelatedToVia private Set&lt;HasQuestionRelationship&gt; question = new HashSet&lt;HasQuestionRelationship(); </code></pre> <p>and save just the root. That brings me to this problem: <a href="http://forum.springsource.org/showthread.php?124316-Spring-Data-Neo4j-NullPointerException-with-RelatedToVia" rel="nofollow">http://forum.springsource.org/showthread.php?124316-Spring-Data-Neo4j-NullPointerException-with-RelatedToVia</a> and this open issue <a href="https://jira.springsource.org/browse/DATAGRAPH-216?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel#issue-tabs" rel="nofollow">https://jira.springsource.org/browse/DATAGRAPH-216?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel#issue-tabs</a></p> <p>then i tried to save just one relation:</p> <pre><code>@RelatedToVia(elementClass=HasQuestionRelationship.class, type="HAS_QUESTION", direction=Direction.OUTGOING) private HasQuestionRelationship question2; </code></pre> <p>my relation class looks like:</p> <pre><code>@RelationshipEntity(type="HAS_QUESTION") public class HasQuestionRelationship { @GraphId Long id; private String name; @StartNode private QuestionnaireNode questionnaire; @EndNode private QuestionNode question; public HasQuestionRelationship() { } public HasQuestionRelationship(QuestionnaireNode questionnaireNode, QuestionNode question, String string) { if (question == null) System.out.println("csxa"); this.questionnaire = questionnaireNode; this.question = question; this.name = string; } public String getName() { return name; } public void setName(String name) { this.name = name; } public QuestionnaireNode getQuestionnaire() { return questionnaire; } public void setQuestionnaire(QuestionnaireNode questionnaire) { this.questionnaire = questionnaire; } public QuestionNode getQuestion() { return question; } public void setQuestion(QuestionNode question) { this.question = question; } } </code></pre> <p>my class questionnaire looks like this:</p> <pre><code>public class QuestionnaireNode extends BaseNode { @RelatedToVia(elementClass=HasQuestionRelationship.class, type="HAS_QUESTION", direction=Direction.OUTGOING) private HasQuestionRelationship question2; public QuestionnaireNode() {} public QuestionnaireNode(String name) { setName(name); } public QuestionnaireNode(String name, QuestionNode question) { setName(name); this.question2 = new HasQuestionRelationship(this, question, "testrelation"); } public HasQuestionRelationship getQuestion2() { return question2; } public void setQuestion(HasQuestionRelationship question) { this.question2 = question; } } </code></pre> <p>Now, I tried to save some testdata:</p> <pre><code> QuestionNode question = new TextQuestionNode("question"); QuestionnaireNode questionnaire = new QuestionnaireNode("questionnaire"); HasQuestionRelationship relationtype = new HasQuestionRelationship(questionnaire, question, "mytest"); questionnaire.setQuestion(relationtype); try { myRepository.save(question); myRepository.save(questionnaire); } catch (Exception e) { e.printStackTrace(); } </code></pre> <p>No exception is thrown. Im happy, but if i look into my database, i see just 2 nodes, but no relationship between them. Where is my fault?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload