[Neo4j] spring data neo4j Relationships

2011-12-01 Thread Martin Junghanns
Hey,

after reading the docs and looking at the examples, I give up trying to 
find a solution for myself. The problem is the following: How are 
@RelationshipEntity classes persistet? I have the same stucture as in 
the Movies Example: the classes Actor -- Role -- Movie. When adding a 
new Role to an Actor and saving the Actor Entity using the 
ActorRepository, the new edges are not persisted in the database. Do I 
have to persist the Role Entities manually? If yes, what Repository 
shall I use for that?

this is part of my Actor class

 @GraphId
 private Long id;

 // 1:n relation
 @RelatedToVia
 CollectionTMS_Rel OpTmRs;
// 1:1 relation to store the latest link ... this works and the 
ede is persistet
 private TMS OpTmRs_Latest;


this is part of my Role class

 @GraphId
 Long id;

 @StartNode
 WTUR wturInstance;
 @EndNode
 TMS tmsInstance;

 long timestamp;

and finally this is the other end of the edge, my Movie class

 @GraphId
 private Long id;

 @RelatedTo(type = TMS_REL, direction = INCOMING)
 SetWTUR wturs;

 @RelatedToVia(type = TMS_REL, direction = INCOMING)
 IterableTMS_Rel tmsRels;

So, all single edges work perfectly, but the sets don't. Hope someone 
can help me out with that


Greetings, Martin
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] spring data neo4j Relationships

2011-12-01 Thread Michael Hunger
Martin,

are you using the simple mapping (w/o AJ) or the advanced AspectJ mapping?

I assume the simple mapping:

There are several ways of persisting a RelationshipEntity()

* (template or repository).createRelationshipBetween()
* (template or repository).save(new Role(movie, actor, rolenName));
* node-entity with @Fetch @RelatedToVia SetRole roles=new HashSetRole();

actor = (template or repository).findOne(actorId); // or other loading 
mechanisms
actor.roles.add(new Role(movie, actor, rolenName));
(template or repository).save(actor)

if you are not using the first approach, you have to provide a RelationshipType 
for Role 
* as part of the @RelationshipEntity(type=TYPE) annotation
* or as a @RelationshipType String type; field

We can also have a skype call if you want to clarify things.

HTH,

Michael

Am 01.12.2011 um 12:49 schrieb Martin Junghanns:

 Hey,
 
 after reading the docs and looking at the examples, I give up trying to 
 find a solution for myself. The problem is the following: How are 
 @RelationshipEntity classes persistet? I have the same stucture as in 
 the Movies Example: the classes Actor -- Role -- Movie. When adding a 
 new Role to an Actor and saving the Actor Entity using the 
 ActorRepository, the new edges are not persisted in the database. Do I 
 have to persist the Role Entities manually? If yes, what Repository 
 shall I use for that?
 
 this is part of my Actor class
 
 @GraphId
 private Long id;
 
 // 1:n relation
 @RelatedToVia
 CollectionTMS_Rel OpTmRs;
// 1:1 relation to store the latest link ... this works and the 
 ede is persistet
 private TMS OpTmRs_Latest;
 
 
 this is part of my Role class
 
 @GraphId
 Long id;
 
 @StartNode
 WTUR wturInstance;
 @EndNode
 TMS tmsInstance;
 
 long timestamp;
 
 and finally this is the other end of the edge, my Movie class
 
 @GraphId
 private Long id;
 
 @RelatedTo(type = TMS_REL, direction = INCOMING)
 SetWTUR wturs;
 
 @RelatedToVia(type = TMS_REL, direction = INCOMING)
 IterableTMS_Rel tmsRels;
 
 So, all single edges work perfectly, but the sets don't. Hope someone 
 can help me out with that
 
 
 Greetings, Martin
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user