2 Replies Latest reply on Feb 4, 2011 10:24 AM by Sudheer Krishna

    Basic doubt on cache transaction when modifying cache value by reference

    Sudheer Krishna Novice

      Since infinispan cache works by identify, I understand that changing the value of the object reflects in changing the value of the cache.




      Person p = new Person("Sudheer");  //Assuming person is a custom object with a single strring as its content.




      Now when i execut ethe following code


      Person person = (Person) cache.get("key1");


      person.setName("newName");  //This value is also update in teh cache since it uses object identity, that it  cache.get("key1") - now returns ->  Person("newname").


      Now what is the expected behaviour when the following happen inside the transaction ,assuming the cache already contains ("key1", Person("Sudheer") )




      1.   ut.begin()


          Person person = (Person) cache.get("key1");




          ....... other statements






         Person person = (Person) cache.get("key1");




          person.setName("newName"); -- ?/is this statement considers as cache operation.????


          ....... other statements





      Are 1 and 2 same ?


      Infinispan doc says - http://community.jboss.org/wiki/Infinispantransactions


      "On every cache operation Infinispan does the following:" .......  My doubt is,  Is operation on the cache  value(person.setName() above)  considered as cache operation ?


      If yes -  In case 2 above is a local copy of Person maintained inside transaction  to ensure that changes inside transaction are not reflected to objects outiside ?


      If no - Is there any other way to ensure that value objects can be modified within scope of a transaction.?