خرید بک لینک

Vote count: 0

Let's say, i have an User and a Product. The user should be able to rate products and a rating can have a lot of properties like for example a number of stars from 1 to 5. I'd like to have the Product and the User in different Maven modules. However, Product should know its Owner, so there is a dependency to the module, holding User. I also would like to have a Rating-Module that contains everything related to ratings.

I constructed the Rating

@RelationshipEntity(type="RATES")
public class Rating{
  private Long id;
  @StartNode
  private User rater;
  @EndNode
  private Product ratee;
  @Property
  private RatingProperty property;
  //Getter/Setter
}

Where the RatingProperty contains the int representing the 1 to 5 star rating. Now I understand from the Documentation that I need to have the Rating as an attribute inside some node because SDN4 doesn't accept it otherwise. Indeed when i did not use it as an attribute and tried save it, i got the id null and not element appeared in the DB. Since the Rating needs to know both User and Product, I get a cyclic dependency when I try to put the Rating into the User class. The same when i put it into the Product Class.

As far as I understand at the moment, using a RelationshipEntity seems to not be possible when the Start- and EndNode entities are in different Maven Modules, because the Relationship needs to know both and one of the nodes needs to know the relationship. This doesn't seem right, so I think I understand something very wrong. I also tried creating a new NodeEntity inside the Rating-Module just to hold the Rating. This was

@NodeEntity
public class RatingWrapper{
  private Long id;
  @Relationship(type="RATES)
  private Rating rating;
  //Getter/Setter
}

but this way i got the same behavior that i did when i didn't use the RelationshipEntity as an attribute somewhere.

Do you see a way to do this better?

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 1 ارديبهشت 1395 ساعت: 20:08

صفحه بندی