Understanding projectTo in SDN

41 views
Skip to first unread message

Stacy Tyler Young

unread,
Aug 17, 2012, 6:43:52 PM8/17/12
to Neo4j
Inside beforeCommit() of my txn event handler I am setting a field on the node. I need to make that value available in the spring context. I've tried projectTo but not sure I'm understanding its use:

            node.setProperty( "key", "foo" );
            String className = node.getProperty("__type__").toString();
            Class cls = Class.forName( className );
            template.projectTo( node, cls );


Stacy Tyler Young

unread,
Aug 17, 2012, 9:41:09 PM8/17/12
to Neo4j
Took a look at the Neo4jEntityPersister source, ok so projectTo is not what I had thought.

Which leads me back to the original question, is it possible to update node properties during a transaction and them reflected back in spring context?

Thanks!
Stace


Should properties set directly on the node inside a txn event handler be visible 

Michael Hunger

unread,
Aug 18, 2012, 3:05:42 AM8/18/12
to ne...@googlegroups.com
projectTo creates a new entity instance around your node. If you save it, your change will be persisted. But it is not updated in the original entity instance, b/c there is no local cache.

Would it be possible for this specific use-case to hold your own entity cache? (only of those entity types that are potentially updated) ?

Another possible option is to use template.fetch(entity) after the commit.

HTH,

Michael

--
 
 

Reply all
Reply to author
Forward
0 new messages