Results 1 to 3 of 3

Thread: Neo4j: Node as RelationshipEntity-Property

  1. #1

    Default Neo4j: Node as RelationshipEntity-Property

    Hi,

    i am trying to create a relationship between two entities "guest" and "product" with the additional information of an "orderPoint", which is itself an entity.

    Code:
    @NodeEntity
    public class OrderPoint extends DescribedEntity {
       ...
    }
    
    @RelationshipEntity(type = "orders")
    public class Order implements Serializable {
       ...
       protected Date createdAt;
    
       @Fetch
       @RelatedTo(type = "ordersAt")
       @NotNull
       protected OrderPoint orderPoint;
       ...
    }
    Order.createdAt works fine, Order.orderPoint does not. I am able to set the orderPoint and to save the relationship without an error, but i cannot fetch the orderPoint afterwards. Well, saving the relationship without an error doesn't mean it has to work.. is Spring Data Neo4j able to work this way?

    I am using Spring Data Neo4j 2.1. Snapshot.

    Greetz,
    Markus Schulte

  2. #2
    Join Date
    May 2012
    Posts
    107

    Default

    Markus,

    The underlying storage literally cannot do what you ask. So you need to turn that relationship into a node to be able to link it three ways.

    As for SDN, are you saying the behaviour ought to be that when you try to do what you did, some validation should happen and an error message should pop up? In that case, feel free to help us with the design: https://jira.springsource.org/browse/DATAGRAPH - I'd suggest using the form of a failing test that illustrates what you would like to see?

    Regards,

    Lasse

  3. #3
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    Sounds like a vertex node. I have a few of those in my application, and yes you have to make it its own node. Basically, you wanted a single relationship to relate three separate nodes. a Relationship can only relate between two nodes.

    It really isn't bad that you have to create a vertex node, you will now have three separate relationships in that node between the three outer nodes. But that then means that for each node in the vertex node/relationship can each have its own type and values. So in reality I view having to create a separate vertex node is much more powerful.

    Thanks

    Mark

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •