spring-projects / spring-data-neo4j

Provide support to increase developer productivity in Java when using Neo4j. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
http://spring.io/projects/spring-data-neo4j
Apache License 2.0
833 stars 618 forks source link

Replace current "Outside of transaction strategy" with nested Neo4j transactions [DATAGRAPH-38] #605

Closed spring-projects-issues closed 13 years ago

spring-projects-issues commented 13 years ago

Michael Hunger opened DATAGRAPH-38 and commented

After rereading the neo4j transaction wiki page I'm pondering the idea to drop the current code for transaction participation ind spring-data-graph.

Current approach is: when I'm in a transaction just write the property back to the graph (or modify the relationship or create the node). When I'm outside of a transaction just store the value in the java object. Whenever I'm back in a transaction write back all modified values in one go.

I could change that and replace that the way that all modifying operations would be wrapped in a neo4j transaction. That would ensure that they succeed regardless an outer transaction.

How is the penalty for creating a nested transaction on each property write? A: Quite cheap, since a nested transaction isn't a nested transaction... it just returns a fake Transaction instance, no extra overhead.

And there is one scenario where this does not fit: Frameworks and people create throwaway entities all the time (e.g. in the web layer). If I wrap node creation in a transaction it would always create a node even for those entities that are never intended to be stored. The current approach just doesn't flush those entities because they never get near a transaction. A solution for that could be, that node creation is never automatically wrapped in a transaction just modifications of entities that are backed by existing nodes.


Affects: 1.0 M3

This issue is a sub-task of DATAGRAPH-45

spring-projects-issues commented 13 years ago

Andreas Kollegger commented

Neo4j Story #41

spring-projects-issues commented 13 years ago

Michael Hunger commented

Default strategy for @NodeEntity(autoAttach=true)