在我Neo4j 3.0.1
和SDN 4.1.1.RELEASE
項目,我有以下實體:Neo4j的3.0.1 SDN 4.1.1.RELEASE幻象節點
@NodeEntity
public class CriterionGroup extends Authorable {
private final static String DEFINED_BY = "DEFINED_BY";
private final static String CONTAINS = "CONTAINS";
private String name;
private String description;
@Relationship(type = DEFINED_BY, direction = Relationship.OUTGOING)
private Decision owner;
@Relationship(type = CONTAINS, direction = Relationship.OUTGOING)
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;
....
@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 = CONTAINS, direction = Relationship.INCOMING)
private Set<Decision> parentDecisions = new HashSet<>();
@Relationship(type = CONTAINS, direction = Relationship.OUTGOING)
private Set<Decision> childDecisions = new HashSet<>();
@Relationship(type = DEFINED_BY, direction = Relationship.INCOMING)
private Set<CriterionGroup> criterionGroups = new HashSet<>();
@Relationship(type = DEFINED_BY, direction = Relationship.INCOMING)
private Set<Criterion> criteria = new HashSet<>();
....
在我的測試我試圖用以下方法庫中刪除CriterionGroup
:
@Query("MATCH()-[r]-(cg:CriterionGroup) WHERE id(cg) = {criterionGroupId} DELETE cg, r")
void deleteCriterionGroup(@Param("criterionGroupId") Long criterionGroupId);
然後我試圖通過ID來獲得這個CriterionGroup
criterionGroupRepository.findOne(id);
並且它返回NULL。到現在爲止還挺好。
緊接着,我試圖擺脫Criterion
組對象是在被刪除CriterionGroup
並返回..刪除CriterionGroup
criterionRepository.findOne(criterion.getId()).getGroup()
我在做什麼錯?一切工作正常SDN 3.4.4.RELEASE
和Neo4j 2.3.3
但Neo4j 3.0.1
SDN 4.1.1.RELEASE
由於我知識有限,我有很多意想不到的情況。
此外,有好有以下關係定義在一個實體(我已刪除enforceTargetType
)
@Relationship(type = CONTAINS, direction = Relationship.INCOMING)
private Set<Decision> parentDecisions = new HashSet<>();
@Relationship(type = CONTAINS, direction = Relationship.OUTGOING)
private Set<Decision> childDecisions = new HashSet<>();
他們有不同的方向。
感謝您的回答。獲得對Session對象的引用的正確方法是什麼?另外,對於'Decision.parentDecisoins'我有以下方法 - '設置 getParentDecisions()','addParentDecision(決策決定)','removeParentDecision(決策決定)'..應該所有的人也可以用'@Relationship註解(type = CONTAINS,direction = Relationship.INCOMING)'?如果是這樣,爲什麼我們需要這種冗餘? –
brunoid
我找到了一個如何訪問Session的方法。但'session.detachNodeEntity(criterionGroupId);'不起作用。但'session.clear();'也清除所有其他對象,所以我現有的所有測試都失敗了。 – brunoid
另外,您是否有計劃自動同步OGM和自定義Cypher查詢執行之間的狀態? – brunoid