2016-05-24 12 views
1

Ich bin von SDN 3 bis SDN 4 und von Neo4j 2.3 bis 3.0.1Spring Data Neo4j 4 Repository-Methode gibt 1 Element

auf neue Abhängigkeiten meinem Test mit einer Behauptung nicht bewegt. Anstelle von 3 Knoten gibt es nur einen zurück.

@NodeEntity 
public class Decision extends Commentable { 

    private final static String CONTAINS = "CONTAINS"; 
    private final static String DEFINED_BY = "DEFINED_BY"; 
    private final static String VOTED_FOR = "VOTED_FOR"; 

    private String name; 

    @Relationship(type = DEFINED_BY, direction = Relationship.INCOMING) 
    private Set<Criterion> criteria = new HashSet<>(); 

.... 


@NodeEntity 
public class Criterion extends Authorable { 

    private final static String CONTAINS = "CONTAINS"; 
    private final static String DEFINED_BY = "DEFINED_BY"; 

    private String name; 

    private String description; 

    @Relationship(type = CONTAINS, direction = Relationship.INCOMING) 
    private CriterionGroup group; 

    @Relationship(type = DEFINED_BY, direction = Relationship.OUTGOING) 
    private Decision owner; 


@Test 
    public void testGetChildDecisionsSortedBySumOfCriteriaAvgVotesWeightWithCoefficients() { 
     User user = userService.createUser("test", "test", "[email protected]", null, null); 

     final Decision rootDecision1 = decisionDao.create("Root decision1", "Root decision 1 description", null, user); 

     final Criterion rootDecision1Criterion1 = criterionDao.create("rootDecision1Criterion1", "rootDecision1Criterion1", rootDecision1, user); 
     final Criterion rootDecision1Criterion2 = criterionDao.create("rootDecision1Criterion2", "rootDecision1Criterion2", rootDecision1, user); 
     final Criterion rootDecision1Criterion3 = criterionDao.create("rootDecision1Criterion3", "rootDecision1Criterion3", rootDecision1, user); 

     assertEquals(3, criterionDao.getCriteriaDefinedByDecision(rootDecision1.getId()).size()); 

Repository-Methode:

@Query("MATCH (d:Decision)<-[:DEFINED_BY]-(c:Criterion) WHERE id(d) = {decisionId} RETURN c") 
List<Criterion> getCriteriaDefinedByDecision(@Param("decisionId") Long decisionId); 

Was ein Grund für dieses Problem sein kann und wie man es beheben?

AKTUALISIERT

ich, dass der Bau

public Criterion(String name, String description, Decision owner, User author) { 
     this.name = name; 
     this.description = description; 
     this.owner = owner; 
     setAuthor(author); 
    } 
für SDN 4 um

ist nicht genug gefunden ONE_TO_MANY Assoziation zu schaffen .. Ich muss zusätzliche Zeilen hinzufügen, um Objekt zu übergeordneten Sammlung hinzufügen ebenfalls.

public Criterion(String name, String description, Decision owner, User author) { 
     this.name = name; 
     this.description = description; 
     this.owner = owner; 
     if (owner != null) { 
      owner.addCriterion(this); 
     } 
     setAuthor(author); 
    } 

Was mache ich falsch?

Antwort

0

hatten das gleiche Problem, versucht DEFINED_BY @Relationship von Criterion

@NodeEntity 
    public class Criterion extends Authorable { 

    private final static String CONTAINS = "CONTAINS"; 
    private final static String DEFINED_BY = "DEFINED_BY"; 

    private String name; 

    private String description; 

    @Relationship(type = CONTAINS, direction = Relationship.INCOMING) 
    private CriterionGroup group; 


} 

Criterion sie zuerst und dann eine Verbindung zu Decision

+0

Dank erstellen zu entfernen, aber ich brauche dieses Feld in Übereinstimmung mit meiner Anwendung Geschäftslogik. Es funktionierte perfekt in der vorherigen Version von SDN. Warum haben sie das geändert? – brunoid

+0

Weiß nicht, habe das gleiche Problem. –

Verwandte Themen