> I think this is probably due to a bug in my code (mostly). I also had some
> code that checked whether properties that were not allowed to be modified
> by the client had been and if so I through an exception and aborted the
> transaction. Part of the problem was that, in addition to my own unit
> test, I was driving this from the Data Browser. It appears that the Data
> Browser issues 2 puts whenever you click the Save button and so I was
> actually getting two transactions. The first worked, the second didn't
> because it appeared that I was getting the previous value for a value I had
> just changed in the TransactionEventHandler. This is because the second
> PUT resent the data in the Data Browser form. I have opened an issue on
> the double-PUT problem, but it looks like the issue I reported below is not
> a bug.
> Thanks for taking the time to look into this.
> -brian
> On Tuesday, October 23, 2012 8:59:33 AM UTC-4, Mattias Persson wrote:
>> I just tried your scenario as closely as possible, with this test (added
>> TransactionEventHandler.**Adapter in case you wonder):
>> @Test
>> public void modifiedPropertyCanByFurtherMo**difiedInBeforeCommit()
>> throws Exception
>> {
>> // Given
>> // -- create node and set property on it in one transaction
>> final String key = "key";
>> final Object value1 = "the old value";
>> final Object value2 = "the new value";
>> final Node node = getGraphDb().createNode();
>> node.setProperty( key, "initial value" );
>> commit();
>> // -- register a tx handler which will override a property
>> getGraphDb().**registerTransactionEventHandle**r( new
>> TransactionEventHandler.**Adapter<Void>()
>> {
>> @Override
>> public Void beforeCommit( TransactionData data ) throws
>> Exception
>> {
>> Node modifiedNode = data.assignedNodeProperties().**
>> iterator().next().entity();
>> assertEquals( node, modifiedNode );
>> modifiedNode.setProperty( key, value2 );
>> return null;
>> }
>> } );
>> // When
>> newTransaction();
>> node.setProperty( key, value1 );
>> commit();
>> // Then
>> assertEquals( value2, node.getProperty( key ) );
>> }
>> and it passes. How is your scenario different from mine?
>> 2012/10/16 brian <blevi...@gmail.com>
>> Hi,
>>> Context:
>>> Neo4j Community 1.8GA
>>> Using REST API from Node.js via the node-neo4j driver
>>> My Node.js code invokes a REST request to update properties on a node by
>>> doing a PUT similar to:
>>> PUT http://localhost:7474/db/data/**node/9/properties<http://localhost:7474/db/data/node/9/properties>(with properties in the payload)
>>> I've written a TransactionEventHandler.**beforeCommit() method in which
>>> I mutate values that have already been changed as part of that REST request
>>> and are therefore returned from TransactionData.**
>>> assignedNodeProperties(). Consider the following code:
>>> Object propValueFromTransaction = entity.getProperty("myprop");
>>> entity.setProperty("myprop", newMutatedValue);
>>> After this code executes and after the entire transaction has committed,
>>> the value of the "myprop" property on the node is propValueFromTransaction,
>>> not newMutatedValue. In other words, my setProperty call appears to have
>>> had no effect.
>>> -brian
>>> On Monday, October 15, 2012 5:56:05 PM UTC-4, Axel wrote:
>>>> Hi Brian,
>>>> not sure that I fully understand your context. Could you write a little
>>>> more about how you're using Neo4j (embedded? REST server? Which driver?
>>>> Server extension?)
>>>> From what I learned from Neo4j transactions, you can't be sure to see
>>>> all changes made in a transaction during the beforeCommit phase:
>>>> http://docs.neo4j.org/chunked/****stable/transactions-events.**htm**l<http://docs.neo4j.org/chunked/stable/transactions-events.html>:
>>>> " Right before a transaction is about to be committed the beforeCommit
>>>> method is called with the entire diff of modifications made in the
>>>> transaction. At this point the transaction is still running so changes can
>>>> still be made. However there’s no guarantee that other handlers will see
>>>> such changes since the order in which handlers are executed is undefined."
>>>> Maybe some of the Neo4j guys can shed a little light on this.
>>>> Cheers
>>>> Axel
>>>> Am 15.10.2012 20:54, schrieb brian:
>>>> Anyone have any guidance on this? I'm completely stumped
>>>> Thanks.
>>>> -b
>>>> --
>>>> --
>>>> Axel Morgner · ax...@morgner.de · @amorgner<https://twitter.com/amorgner>
>>>> c/o Morgner UG · Hanauer Landstr. 291a · 60314 Frankfurt · Germany
>>>> phone: +49 151 40522060 · skype: axel.morgner
>>>> structr - Open Source CMS and Web Framework based on Neo4j:
>>>> http://structr.org
>>>> structr Mailing List and Forum: https://groups.google.com/**foru**
>>>> m/#!forum/structr <https://groups.google.com/forum/#%21forum/structr>
>>>> Graph Database Usergroup "graphdb-frankfurt", sponsored by Neo4j:
>>>> http://www.meetup.com/graphdb-****frankfurt<http://www.meetup.com/graphdb-frankfurt>
>>>> Das Sport-Sharing-Netzwerk des Deutschen Olympischen Sportbundes
>>>> (DOSB): https://splink.de
>>>> --
>> --
>> Mattias Persson, [mat...@neotechnology.com]
>> Hacker, Neo Technology
>> www.neotechnology.com
> --