У меня есть User
:
@NodeEntity
public class User {
@Id
@Index(primary = true)
private Long iD;
private String Name;
private String location;
private int friends;
private boolean verified;
private int followers;
@Relationship(type = "Follows", direction = Relationship.OUTGOING)
private Set<User> follows;
//relate tweets to a particular user
@Relationship(type = "Tweeted", direction = Relationship.OUTGOING)
private Set<Tweeted> tweets;
@Relationship(type = "Mentions", direction = Relationship.INCOMING)
private Set<Mentions> mentioned;
a Tweet
:
@NodeEntity
public class Tweet {
@Id
@Index(primary=true)
@Relationship(type= "Tweeted", direction = Relationship.INCOMING)
private User user;
private int favouriteCount;
private boolean isRetweeted;
private String urlEntities;
private Date date;
private String Text;
private Long tweetedBy;
private Long tweetID;
private int retweetCount;
и отношение Tweeted
:
@RelationshipEntity(type = "Tweeted")
public class Tweeted {
@Id
@GeneratedValue
private long id;
@StartNode
private User user;
@EndNode
private Tweet Tweet;
@Property
private Date date;
, который я считаю, что настроил правильно, чтобы
(User)-[Tweeted]->(Tweet)
отношение. Однако, когда я сохраняю первый твит: с помощью этого метода в моем TweetService
:
public boolean saveTweet(Tweet tweet, User user){
Tweeted tweetRelation = new Tweeted();
tweetRelation.setUser(user);
tweetRelation.setTweet(tweet);
tweetRelation.setDate(tweet.getDate());
try {
//TODO: Mentions!? Deal with them!
tweetrepository.save(tweet);
tweetedRepository.save(tweetRelation);
Твиттер есть, пользователь есть, но между ними нет никакой связи. Может кто-нибудь проверить, правильно ли я настроил постоянство?