Issue 3: Patch: Allow creating relationships to same entity via RelationshipEntity
Status:  New
Owner: ----
Reported by atsuibou...@gmail.com, Nov 13, 2011
What steps will reproduce the problem?
from roo shell execute command(assuming that neo4j project is set up and ~.domain.Person entity is created)
roo> graph relationship --fieldName friends --from ~.domain.Person --to ~.domain.Person --via ~.relations.Friendship --cardinality MANY_TO_MANY --type "Friendship"

What is the expected output? What do you see instead?
Addon should add field
@RelatedToVia(type = "Friendship", direction = Direction.BOTH, elementClass = Friendship.class)
private final Iterable<Friendship> friends = null;
but instead error appears:
Other NodeEntity to com.example.domain.Person not found in relationship

What version of the product are you using? On what operating system?
neo4j-roo-addon 1.1.0.RELEASE
spring roo 1.1.5.RELEASE

Please provide any additional information below.
To solve this issue, please apply my patch from attachment. Two thins are changed:
1) when determining other type of the relationship error is not thrown is there exists exactly one @StartNode and one @EndNode in RelationshipEntity (this simple check is done to determine problems that user might manually introduce when modifying generated RelationshipEntity)

2) added direction constant org.springframework.roo.addon.graph.Direction.BOTH that was missing in the addon enum file (even tough it exists in org.springframework.data.neo4j.core.Direction enum that is used in generated code) as it makes sense to include both incomming and outgoing related nodes when startNode and endNode types are the same.
It also seems to work properly without any further modifications as Spring data graph supports it out of the box.
Nov 13, 2011
#1 atsuibou...@gmail.com
...and here is the patch that would solve the issue :)
relateToSameType.patch.txt
3.9 KB   View   Download
Mar 14, 2012
#2 andy...@gmail.com
Has this been implemented and published in any forked projects? What would it take to get this added? I am running into the same issue. I have patched the add-on locally, but I'd rather not duplicate this effort.