<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic JPA integration not working 100% for transient variables??? in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109161#M76598</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've setup JPA integration and initially it seems to work, but I find a deviation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My entity classes all extend an AbstractBean class where the code for a.o. property change events is present. This class also has the possibility to block (ignore) these events (this is required when setting up default values, you do not want the entity to become marked "dirty"). Anyhow, in order to block these events there is a transient property in the abstract bean class:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;@Transient transient final public AtomicInteger ignoreChangesGate = new AtomicInteger();&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I've changed that property temporarly to public, so I can inspect it. Now, when a entity is put into the variables map at the starting of a workflow, this property naturally is not null:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Map&amp;lt;String, Object&amp;gt; lProcessVariables = new HashMap&amp;lt;&amp;gt;();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lProcessVariables.put("a", this);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("!!!1 iIgnoreChangesGate = " + this.ignoreChangesGate);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ProcessInstance lProcessInstance = lProcessEngine.getRuntimeService().startProcessInstanceByKey("frozn", lProcessVariables);&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;A bit later in the process a task listener is called, which fetches this variable:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Override&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void notify(org.activiti.engine.delegate.DelegateTask delegateTask)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Application lApplication = (Application)delegateTask.getVariable("a");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("!!!2 iIgnoreChangesGate = " + lApplication.ignoreChangesGate);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;…&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;When this workflow is run, the following output appears on the console:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;!!!1 iIgnoreChangesGate = 0&lt;BR /&gt;!!!2 iIgnoreChangesGate = null&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;The transient property has not been initialized?!! This is very strange, since it is final and the constructor has finished. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So as a test I simply reloaded the entity from the EM.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Override&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void notify(org.activiti.engine.delegate.DelegateTask delegateTask)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Application lApplication = (Application)delegateTask.getVariable("a");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("!!!2 iIgnoreChangesGate = " + lApplication.ignoreChangesGate);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// reload&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lApplication = (Application)lEntityManager.find(Application.class, lApplication.getApplicationId());&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("!!!3 iIgnoreChangesGate = " + lApplication.ignoreChangesGate);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;…&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;The output now is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;!!!1 iIgnoreChangesGate = 0&lt;BR /&gt;!!!2 iIgnoreChangesGate = null&lt;BR /&gt;!!!3 iIgnoreChangesGate = 0&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;So something is not going right when restoring the entity.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Sep 2012 08:52:51 GMT</pubDate>
    <dc:creator>tbee</dc:creator>
    <dc:date>2012-09-06T08:52:51Z</dc:date>
    <item>
      <title>JPA integration not working 100% for transient variables???</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109161#M76598</link>
      <description>I've setup JPA integration and initially it seems to work, but I find a deviation.My entity classes all extend an AbstractBean class where the code for a.o. property change events is present. This class also has the possibility to block (ignore) these events (this is required when setting up default</description>
      <pubDate>Thu, 06 Sep 2012 08:52:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109161#M76598</guid>
      <dc:creator>tbee</dc:creator>
      <dc:date>2012-09-06T08:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: JPA integration not working 100% for transient variables???</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109162#M76599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have async behavior in your process definition?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you create a unit test that shows this behavior?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 09:32:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109162#M76599</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2012-09-06T09:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: JPA integration not working 100% for transient variables???</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109163#M76600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I do not have an async process. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'vecreated my own implementation, which generates a String from an entity (classname:id) and reloads the entity based on the information in the listener. This works without a problem. (It also has the advantage that, because I mix and match workflow and regular code, it makes sure only one EntityManager is used; no conflicts.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A unit test, well it is happening as part of my own unit test, so I could strip that down… I'll give it a try.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 10:02:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109163#M76600</guid>
      <dc:creator>tbee</dc:creator>
      <dc:date>2012-09-06T10:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: JPA integration not working 100% for transient variables???</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109164#M76601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yeah. Now that I've stripped it down far enough, the problem is gone. So there is some kind of conflict between what I do in the frame of my application, and how Activiti restores the entity. So I can't give you a simple unit test that reproduces the problem. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I do know is that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- in the activiti implementation a final field ends up being null (that is very strange)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- using my simple implementation of encode-as-string and find-using-string in the same context works fine&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My question would be: what magic are you guys doing to restore the entity? It seems the constructor is somehow by passed. (Note that I have 5 layer deep entity classes.) As said, this simple piece of code works fine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt; static public &amp;lt;T&amp;gt; T fromId(Object id)&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; try&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // preconditions&lt;BR /&gt;&amp;nbsp;&amp;nbsp; String lId = "" + id;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if ("null".equals(lId)) return null;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; // split id&lt;BR /&gt;&amp;nbsp;&amp;nbsp; int lIdx = lId.indexOf(":");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; String lClassname = lId.substring(0, lIdx);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; BigInteger lPK = new BigInteger(lId.substring(lIdx + 1));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; // get entity&lt;BR /&gt;&amp;nbsp;&amp;nbsp; EntityManager lEntityManager = EntityManagerFinder.find();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; T lEntity = (T)lEntityManager.find(Class.forName(lClassname), lPK);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return lEntity;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; catch (ClassNotFoundException e) { throw new IllegalStateException(e); }&lt;BR /&gt; }&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;I can offer you to take a remote-desktop peek in my development environment.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 10:45:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109164#M76601</guid>
      <dc:creator>tbee</dc:creator>
      <dc:date>2012-09-06T10:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: JPA integration not working 100% for transient variables???</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109165#M76602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm. I've taken a peek at what is in the ACT_RU_VARIABLE table and I see that my approach stores a "nl.o837.frozn.bm.Application:74" text. However, Activiti seems to store a serializable. Do you actually serialize and store the whole entity? That should not be, the user manual says "&lt;/SPAN&gt;&lt;EM&gt;When the variable is requested the next time, it will be loaded from the EntityManager based on the class and Id stored.&lt;/EM&gt;&lt;SPAN&gt;".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 13:32:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109165#M76602</guid>
      <dc:creator>tbee</dc:creator>
      <dc:date>2012-09-06T13:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: JPA integration not working 100% for transient variables???</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109166#M76603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's the "transient" keyword; it tells Java's serializer to not serialize a field. And that is how you get a final field to become null…&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 14:58:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/jpa-integration-not-working-100-for-transient-variables/m-p/109166#M76603</guid>
      <dc:creator>tbee</dc:creator>
      <dc:date>2012-09-06T14:58:29Z</dc:date>
    </item>
  </channel>
</rss>

