getElements() returns a set of your elements. If you do an add(element) on 
those then you build up an in-memory structure.

So if you use just the getters and setters of your instances you can navigate 
this structure, but you can't use any of the graph operations supplied by neo4j 
(remember it is still just in memory)

Cheers

Michael

Am 22.06.2011 um 17:06 schrieb V:

> Michael - 
> 
> In my quest for a cleaner solution , I am coming back to your original reply
> 
> What do you mean by "Right now this works only with the getElements().add 
> method."
> Please elaborate . 
> 
> Thanks for your help .
> 
> 
> On Sun, Jun 19, 2011 at 2:34 AM, Michael Hunger 
> <michael.hun...@neotechnology.com> wrote:
> Right now this works only with the getElements().add method.
> 
> But then you don't get all the graph methods (traversals and such).
> 
> We discussed some time ago writing a virtual graph layer on top of the real 
> nodes and relationships for SDG.
> (That should be then used to have a simpler handling of attached/detached 
> nodes and keeping back-references for cluster-persistance).
> 
> 
> But that hasn't happend yet and I'm not convinced it will make it in the 1.1. 
> timeframe.
> 
> Cheers
> 
> Michael
> 
> P.S. You can still persist your graph and remove the nodes later (either 
> index them on a "transient" index or keep their node-id's somewhere).
> 
> 
> Am 18.06.2011 um 03:40 schrieb V:
> 
>> Any suggestions on this please ? 
>> 
>> 
>> On Fri, Jun 17, 2011 at 11:03 PM, V <vlin...@gmail.com> wrote:
>> I created a graph model with 2 classes Node and Element as follows: 
>> 
>> public class Node {
>> 
>>  @RelatedTo(type = "ELEMENT", elementClass = Element.class, direction = 
>> OUTGOING)
>>     private Set<Element> Element;
>> 
>> 
>>     public void addElement(Element e) {
>>         relateTo(e, Relationships.ELEMENT.toString());
>>     }
>> 
>> }
>> 
>> public class Element{
>> 
>>    public String name;
>> 
>> }
>> I want to create an in memory graph structure without persisting the nodes 
>> as follows : 
>> 
>> Node n = new Node();
>> n.addElement(new Element());
>> 
>> However it throws an exception as the Node n has not been persisted so the 
>> call to relateTo(..) fails. 
>> 
>> If instead I do 
>> n.persist()
>> and then call addElement(..) it works fine as the aspect kicks in. 
>> 
>> Any workaround for this ?  That is, is there a way I can still use the above 
>> style without persisting the Node object ? 
>> 
>> 
>> My application needs this as first I create a structure and persist it, and 
>> then I create another structure to pass around some values to the persisted 
>> structure when doing some computations. 
>> 
>> -Karan 
>> 
>> 
>> 
>> 
> 
> 

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

Reply via email to