[Neo] Holding nodes between transactions
emil at neotechnology.com
Thu Sep 25 15:05:16 CEST 2008
On Thu, Sep 25, 2008 at 8:06 AM, Michael Hunger <neo at jexp.de> wrote:
> Thanks for the answers. The main question however remains. I don't know how this is with Software Transactional Memory.
> If you hold nodes between transactions and they are e.g. deleted by another thread/user then your reference is no longer
> valid. Changed properties/relationships shouldn't matter as they are just provided by a transactional neo service. But
> removal is still a problem (imho).
If the node you wrap is deleted "from under you" (for example by
another operation) then you're going to get a runtime exception next
time you invoke a method on that node reference. So it's up to the
layer above to make sure that it invalidates any long-held references
to those nodes. There's nothing we can do to prevent that other than
alerting the client through a runtime exception.
In our applications, we new up domain wrappers very liberally. The
typical "getXXXByYYY()" operations on a service interface are for
example implemented as such:
// pseudo code
Person getPersonByName( String name )
Node underlyingNode = someIndex.getSingleNodeFor( name );
return new PersonImpl( underlyingNode );
And we also make sure that we in data structures in the upper layers
only store identifyers and execute a lookup, rather than references to
the actual nodes or relationships.
Does that help?
Emil Eifrém, CEO [emil at neotechnology.com]
Neo Technology, www.neotechnology.com
Cell: +46 733 462 271 | US: 206 403 8808
More information about the User