Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Relationship classes with the same type
    primarykey
    data
    text
    <p>Using spring-data-neo4j, I want to create two classes using <code>@RelationshipEntity(type="OWNS")</code> to link a <code>Person</code> class to both a <code>Pet</code> and <code>Car</code>.</p> <pre><code>@RelationshipEntity(type="OWNS") public class OwnsCar { @Indexed private String name; @StartNode private Person person; @EndNode private Car car; } @RelationshipEntity(type="OWNS") public class OwnsPet { @Indexed private String name; @EndNode private Person person; @StartNode private Pet pet; } </code></pre> <p>This saves to the Graph Database properly with no problems, as I can query the actual <code>Node</code> and <code>Relationship</code> and see they <strong>type</strong>, etc. </p> <p>But when I attempt to use <code>@RelatedTo(type="OWNS", elementClass=Pet.class)</code> I either get a class cast exception, or when using lazy-initialization I get incorrect results.</p> <pre><code>@NodeEntity public class Person { @Indexed private String name; @RelatedTo(type="OWNS", direction=Direction.OUTGOING, elementClass=Pet.class) private Set&lt;Pet&gt; pets; @RelatedTo(type="OWNS", direction=Direction.OUTGOING, elementClass=Car.class) private Set&lt;Car&gt; cars; } </code></pre> <p>The result I get when I attempt to print our my person(my <code>toString()</code> has been omitted, but it simply calls the <code>toString()</code> for each field) is this:</p> <pre><code>Person [nodeId=1, name=Nick, pets=[Car [nodeId=3, name=Thunderbird]], cars=[Car [nodeId=3, name=Thunderbird]]] </code></pre> <p>Does anyone know if this can be done, should be done, is just a bug or a feature that is missing?</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