We have a reflexive relationship which doesn't seem to come out of the database properly:
Code:
class AbstractEquipment {
...
@ManyToOne(optional = true, fetch = FetchType.EAGER)
@JoinTable(name = "EQUIPMENT_ABSTRACTEQUIPMENT_PARENT")
private com.nokia.nspos.model.domain.equipment.entities.AbstractEquipment parent;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true)
private java.util.List<com.nokia.nspos.model.domain.equipment.entities.AbstractEquipment> children;
...
}
The parent field seems to get populated correctly, but the children collection always contains the parent in addition to the children that were persisted.
I have all the Cypher queries, but I think this one is the one that is intended to fetch the children:
Code:
neo4j-sh (?)$ MATCH (owner:ENTITY:`EQUIPMENT_ABSTRACTEQUIPMENT` {dbId: 54}) -[r:parent]- (target) RETURN id(target), r, owner, target ORDER BY id(target);
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id(target) | r | owner | target |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 68 | :parent[92]{} | Node[96]{_modelVersion:"1.0.0",_fullClassName:"equipment.Equipment",operState:0,neName:"7750_sim_234",oosReason:0,adminState:1,DTYPE:"equipment_Equipment",sourceType:2,position:"shelf=1/slot=2/card=2/slot=1/card=1",name:"Daughter Card - 2/1",_version:0,type:3,positionId:2,neId:"35.121.0.234",standbyState:1,sourceSystem:"fdn:realm:sam",dbId:54} | Node[68]{_modelVersion:"1.0.0",_fullClassName:"equipment.EquipmentHolder",operState:0,_version:0,sourceType:2,oosReason:0,adminState:1,neId:"35.121.0.234",neName:"7750_sim_234",DTYPE:"equipment_EquipmentHolder",actualType:"1",position:"shelf=1/slot=2/card=2/slot=1",name:"Daughter Card Slot - 2/1",type:3,positionId:2,holderState:1,provisionedType:"4096",standbyState:1,sourceSystem:"fdn:realm:sam",dbId:47} |
| 196 | :parent[192]{} | Node[96]{_modelVersion:"1.0.0",_fullClassName:"equipment.Equipment",operState:0,neName:"7750_sim_234",oosReason:0,adminState:1,DTYPE:"equipment_Equipment",sourceType:2,position:"shelf=1/slot=2/card=2/slot=1/card=1",name:"Daughter Card - 2/1",_version:0,type:3,positionId:2,neId:"35.121.0.234",standbyState:1,sourceSystem:"fdn:realm:sam",dbId:54} | Node[196]{oosReason:0,adminState:1,operState:2,_modelVersion:"1.0.0",sourceType:2,_fullClassName:"equipment.Equipment",neId:"35.121.0.234",neName:"7750_sim_234",description:"10-Gig Ethernet",_version:0,position:"shelf=1/slot=2/card=2/slot=1/card=1/port=1",DTYPE:"equipment_Equipment",type:9,positionId:1,name:"Port 2/1/1",standbyState:1,sourceSystem:"fdn:realm:sam",dbId:79} |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows
59 ms
I think there needs to be a direction constraint on the edge [r:parent] like this:
Code:
neo4j-sh (?)$ MATCH (owner:ENTITY:`EQUIPMENT_ABSTRACTEQUIPMENT` {dbId: 54}) <-[r:parent]- (target) RETURN id(target), r, owner, target ORDER BY id(target);
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id(target) | r | owner | target |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 196 | :parent[192]{} | Node[96]{_modelVersion:"1.0.0",_fullClassName:"equipment.Equipment",operState:0,neName:"7750_sim_234",oosReason:0,adminState:1,DTYPE:"equipment_Equipment",sourceType:2,position:"shelf=1/slot=2/card=2/slot=1/card=1",name:"Daughter Card - 2/1",_version:0,type:3,positionId:2,neId:"35.121.0.234",standbyState:1,sourceSystem:"fdn:realm:sam",dbId:54} | Node[196]{oosReason:0,adminState:1,operState:2,_modelVersion:"1.0.0",sourceType:2,_fullClassName:"equipment.Equipment",neId:"35.121.0.234",neName:"7750_sim_234",description:"10-Gig Ethernet",_version:0,position:"shelf=1/slot=2/card=2/slot=1/card=1/port=1",DTYPE:"equipment_Equipment",type:9,positionId:1,name:"Port 2/1/1",standbyState:1,sourceSystem:"fdn:realm:sam",dbId:79} |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row
32 ms
If that's not the one let me know. I can submit the other queries and results too.