Your code doesn't need to be littered with transaction management. You can have a very big MVC (Model-View-Controller) application or something like that and _only_ have transaction handling in one place... in the Controller.
See http://wiki.neo4j.org/content/Transactions#Best_practices (page under construction) 2010/1/12 Laurent Laborde <[email protected]>: > On Tue, Jan 12, 2010 at 6:41 AM, Ryan Levering <[email protected]> wrote: >> >> 1. User.getName() >> >> I want a property off the node. I assume I encapsulate the single >> internal getProperty call in a transaction? My accessor code has just >> quadrupled in size, even if I am ok with this silly, time-consuming >> transaction. Leaving it out means every piece of code in my system >> has to understand to start a neo4j transaction just to get the user's >> name. >> >> 2: for (User user : getUsers()) >> >> I want to do something to all the users in the system. There are A >> LOT of them and they are all linked to a UserFactory or whatever. I >> can't create an internal list, because they won't all fit in memory. >> So I wrap the Iterable<Relationship/Node> in an Iterable that wraps >> the nodes in POJOs. Only there is no way to do this without enclosing >> that loop in a transaction. > > Ha ! Thank you for explaining my problem and POV in a much more > readable english than me :) > >> Do people just create giant transactions that wrap their entire >> programs since they don't work with large graphs/models? Or is your >> code entirely littered with transaction = service.beginTx(); >> transaction.success(); transaction.finish()? > > When i can, i have short transaction everywhere. > When i have a very big traverser to do ... well... i have a top-level > transaction. > Another workaround i use is to fill an array with the traverser, and i > work on the array. > That why i switched to 8GB on my desktop PC -_-' > >> I've looked around on the wiki and site and I can't find good answers >> to these questions. The IMDB example transactionalizes things at a >> very high level. In a sense, wrapping the entire program (web >> request) in a single transaction. I guess that's fine if you have >> small operations and use Spring injection, but what if you don't? > > You do it the Oracle(tm) way : buy more ram :) > > -- > Laurent "ker2x" Laborde > Sysadmin & DBA at http://www.over-blog.com/ > _______________________________________________ > Neo mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [[email protected]] Neo Technology, www.neotechnology.com _______________________________________________ Neo mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

