SDN 4 missing relationships in the graph

84 Views Asked by At

When I store my Neo4j nodes to the Neo4j graph, only nodes are stored (no relationships). Does anyone can point me to right direction what i am missing there?

here are my nodes

@NodeEntity public class Game extends AbstractEntity{

     public Long        timestamp;
     public double  total_pot_size;

     public int     flop;
     public int     turn;
     public int     river;

     @Relationship(type = "ROUND")
     public Set<Round> rounds;

     @Relationship(type = "OUTCOME")
     public Set<Outcome> outcomes;


     public Game() {
         super();
     }

     public void add(Outcome outcome) {
         if (outcomes == null) {
            outcomes = new HashSet<Outcome>();
         }
         outcomes.add(outcome);
     }

     public void add(Round round) {
         if (rounds == null) {
             rounds = new HashSet<Round>();
         }
        rounds.add(round);
     }
 }

and

@NodeEntity public class Player extends AbstractEntity {

    public String   name;
    public String   platform;

    @Relationship(type = "PARTICIPATION", direction = Relationship.OUTGOING)
    public Set<Participation> involved_games;

    @Relationship(type = "OWNS")
    public Set<Statistics> statistics;

    public Player() {
        super();
    }

    public void participate(Participation involved_game) {
        if (involved_games == null) {
            involved_games  = new HashSet<Participation>();
        }
        involved_games.add(involved_game);
    }

    public void add(Statistics stat) {
        if (statistics == null) {
            statistics  = new HashSet<>();
        }
        statistics.add(stat);
    }
}

here is the code i use to store my data.

    // create or get a new game in database
    Game    game    = gameRepo.save( DataUtil.createGame(gi) );

    // get the player involved to the game
    List<Player> players    = gi.getPlayers();
    // for each player involved to the game...
    for (Player player : players) {
        org.quazar.data.domain.Player p = store(player);
        // relationship participation
        p.participate(DataUtil.createParticipation(p, game, player));
        // set the outcome of the players
        game.add(DataUtil.createOutcome(game, p, gi, player));
        playerRepo.save(p);
    }

    gameRepo.save( game );

the store(player) method saves or retrieve (if not new) a player, which works properly. DataUtil.createParticipation and DataUtil.createOutcome methods creates new relationships (g.e. new Outcome()) and set the properties.

When running my application i do not get any exceptions, but in the graph i miss my relationships.

I did not listed all the nodes (e.g. Statistics) because right now i do not use them in my model, could that cause the problem?

Here are some relationships:

@RelationshipEntity(type = "PARTICIPATION")
public class Participation extends AbstractEntity {

    @StartNode
    public Player   player;

    @EndNode
    public Game     game;

    @Property
    public double   bankroll;

    @Property
    public int      holecards;
    @Property
    public byte     position;

    public Participation () {
        super();
    }

}

and

@RelationshipEntity(type = "OUTCOME")
public class Outcome extends AbstractEntity {

    @StartNode
    public Game     game;

    @EndNode
    public Player   player;

    @Property
    public String   type;

    @Property
    public String   round;

    @Property
    public double   pot_size;
    @Property
    public double   ante;

    @Property
    public int      holecards;
    @Property
    public String   bestHand;
    @Property
    public int      bestHandrank;

    public Outcome() {
        super();
    }
}
0

There are 0 best solutions below