Not that this solves your issue but...

1. If it is a webapp you can use a filter that wraps the request
around a transaction try catch finally... then your code would be
transaction free (mostly)
2. If you use a Spring service you can use @Transational or AOP
interceptors to annotate operations that are transactional.
3. If you use plain old java code... Well isn't the nature of
transactions itself and the fact that you your code may end up in a
exception force you to try catch if you want your transactions to
rollback?. Java exception handling imposed try/catch blocks is to be
blame for this not the fact that you have to programmatically handle
transactions I can think of some nasty solutions where you could weave
your classes to intercept neo calls around transactions without having
to explicitly type transactions but it would still result in one
transaction per operation. In my opinion even client side or console
based apps can benefit from using an IOC container like Spring that
lets you handle transactions with annotations or interceptors.

Having said that, I agree that is not common to have to explicitly
declare a transaction for reads. Maybe neo could internally create
those transactions when needed on reads. I also understand
that in a heavy optimized system locks and writes may be required when
reading if the structures need to be balanced based on usage to
provide a more efficient traversal the next time around.

I agree with you, I run into the same issue when we started working
with neo and found I had to declare transactions around traversers.

2010/1/11 Ryan Levering <[email protected]>:
> I know this has come up a couple of times and that transactions are
> being worked on it Traversers, but I just can't get my head around how
> people use neo4j transactions in general.  When I started writing
> neo4j code a couple days ago, I was amazed at two things: 1) how
> efficient and fast it was and 2) how easy it was to write.  It
> remained that way until I started writing more interesting, deep, and
> large models.
>
> Now, after several days of working with it, I am fed up with
> transaction management in Neo.  I feel that the implementation and
> strict reliance on transactions ruins those two things that I loved
> about it.  I understand transaction management in general and have
> implemented several systems that relied on SQL transaction management,
> but when the simplest read requires a transaction, it makes the code
> very cumbersome.  In addition, my profiling shows that a lot of
> program time is being spent on transaction management in very simple
> reading code.
>
> I'm hoping that the reason is that I just haven't figured out the
> correct usage pattern for working on nodes and, very importantly,
> encapsulating the transaction management in my model.  I'm really
> looking for a solution here, not just criticizing neo4j.  Let's say I
> have a User object, for purposes of example.  Here are two basic
> things I want to do:
>
> 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.
>
> 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()?
>
> 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?
> _______________________________________________
> Neo mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Raul Raja
_______________________________________________
Neo mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to