<div dir="ltr">Hi Faseela,<div><br></div><div>there is blog entry about this subject: <a href="http://blog.infinispan.org/2013/07/store-data-by-reference-or-by-value.html">blog.infinispan.org/2013/07/store-data-by-reference-or-by-value.html</a></div>
<div><br></div><div>but really it is better not to use mutable objects in cache / all application objects which may be accessed by multiple</div><div>threads. You save yourself a lot of clone calls.</div><div><br></div><div>
Regards,</div><div>Zdenek Henek</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Nov 10, 2013 at 7:58 AM, Faseela K <span dir="ltr">&lt;<a href="mailto:faseela.k@ericsson.com" target="_blank">faseela.k@ericsson.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Sanne,<br>
<br>
Thanks for the reply.<br>
Is there any infinispan &quot;get&quot; api, which returns a copy of the actual object, rather than returning the reference?<br>
Because, in my case, I need the value stored in the cache to arrive at the new value.<br>
Just wanted to know if it is possible to solve the issue without cloning the object.<br>
<br>
Thanks,<br>
Faseela<br>
<div class="im HOEnZb"><br>
<br>
-----Original Message-----<br>
From: <a href="mailto:infinispan-dev-bounces@lists.jboss.org">infinispan-dev-bounces@lists.jboss.org</a> [mailto:<a href="mailto:infinispan-dev-bounces@lists.jboss.org">infinispan-dev-bounces@lists.jboss.org</a>] On Behalf Of Sanne Grinovero<br>

Sent: Sunday, November 10, 2013 2:21 AM<br>
To: infinispan -Dev List<br>
</div><div class="HOEnZb"><div class="h5">Subject: Re: [infinispan-dev] Issue with transaction rollback<br>
<br>
Hi Faseela,<br>
you should not attempt to mutate the value retrieved from the Cache.<br>
I would suggest to only store immutable objects in a Cache; in other words rather than invoking a setter on property Name, replace the entry with a new instance of Rollback which has the new name.<br>
<br>
Sanne<br>
<br>
On 9 November 2013 19:31, Faseela K &lt;<a href="mailto:faseela.k@ericsson.com">faseela.k@ericsson.com</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt;    The issue I mentioned below was not related to nested transactions.<br>
&gt;    I debugged further, and the issue narrowed down to the following:<br>
&gt;<br>
&gt;       EmbeddedCacheManager manager = new<br>
&gt; DefaultCacheManager(&quot;config/infinispan-config.xml&quot;);<br>
&gt;       Configuration rc = manager.getCacheConfiguration(&quot;transaction&quot;);<br>
&gt;       manager.defineConfiguration(&quot;test1&quot;, rc);<br>
&gt;       ConcurrentMap&lt;String, Rollback&gt; cache1 = manager.getCache(&quot;test1&quot;);<br>
&gt;       TransactionManager tm =<br>
&gt; manager.getCache(&quot;transaction&quot;).getAdvancedCache().getTransactionManager();<br>
&gt;       Rollback t1 = new Rollback(&quot;k1&quot;, &quot;v1&quot;);<br>
&gt;       cache1.put(&quot;k1&quot;, t1);<br>
&gt;       tm.begin();<br>
&gt;       Rollback tmp = cache1.get(&quot;k1&quot;);<br>
&gt;       tmp.setName(&quot;abcd&quot;);<br>
&gt;       cache1.replace(&quot;k1&quot;, tmp);<br>
&gt;       tm.rollback();<br>
&gt;<br>
&gt;       Even after doing the rollback, &quot;k1&quot; still points to name &quot;abcd&quot;.<br>
&gt;       Only if I do a cache1.get(&quot;k1&quot;).clone(), rollback is functioning<br>
&gt; as expected.<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Faseela<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; ________________________________<br>
&gt; From: <a href="mailto:infinispan-dev-bounces@lists.jboss.org">infinispan-dev-bounces@lists.jboss.org</a><br>
&gt; [mailto:<a href="mailto:infinispan-dev-bounces@lists.jboss.org">infinispan-dev-bounces@lists.jboss.org</a>] On Behalf Of Faseela K<br>
&gt; Sent: Friday, November 08, 2013 6:39 PM<br>
&gt; To: infinispan -Dev List<br>
&gt; Subject: [infinispan-dev] Issue with nested transactions<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt;   I have two osgi bundles, both having two separate caches.<br>
&gt;   I explicitly started a transaction in Bundle 1.<br>
&gt;   Within the transaction, I am accessing Bundle 2&#39;s cache(this is<br>
&gt; implicit transaction, since autocommit is true), and modifying it.<br>
&gt;   Now, there is some operation on Bundle 1&#39;s cache done.<br>
&gt;   After this operation, if I do a roll back,  Only Bundle 1&#39;s cache<br>
&gt; operations are getting rolled back.<br>
&gt;   I am not getting any error, though.<br>
&gt;   Does anyone know why this happens?<br>
&gt;<br>
&gt;   Steps :<br>
&gt;<br>
&gt;     1) Bundle 1 - transaction started<br>
&gt;     2) update bundle 2 cache<br>
&gt;     3) update bundle 1 cache<br>
&gt;     4) Bundle 1 - transaction rollback<br>
&gt;<br>
&gt;     Issue : bundle 2 cache not rolled back!!<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Faseela<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
<br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
</div></div></blockquote></div><br></div>