<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Store variables in DB?
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/nt2005">nt2005</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/649727#649727">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hey Guys,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The 'problem' I have is a bit difficultly to describe, but I will give my best:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I use jBPM 5.2 in a Web-Application at an JBoss 6 AS with a PostgreSQL (just for info).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I start a process in an Seam bean like this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> startProcess() <font color="navy">{</font>
&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; EntityManagerFactory emf = entityManager.getEntityManagerFactory();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; TransactionManagerService tms = <font color="navy"><b>new</b></font> TransactionManagerService();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Environment env = KnowledgeBaseFactory.newEnvironment();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; env.set(EnvironmentName.TRANSACTION_MANAGER, tms.getTransactionManager());
&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Properties properties = <font color="navy"><b>new</b></font> Properties();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; properties.put(<font color="red">"drools.processInstanceManagerFactory"</font>,<font color="red">"org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; properties.put(<font color="red">"drools.processSignalManagerFactory"</font>,<font color="red">"org.jbpm.persistence.processinstance.JPASignalManagerFactory"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);
&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// load up the knowledge base</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; KnowledgeBase kbase = readKnowledgeBase(processid);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, config, env);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; JPAWorkingMemoryDbLogger logger = <font color="navy"><b>new</b></font> JPAWorkingMemoryDbLogger(ksession);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ksession.getWorkItemManager().registerWorkItemHandler(LoadDataWorkItem.NAME, <font color="navy"><b>new</b></font> LoadDataWorkItem());
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ksession.getWorkItemManager().registerWorkItemHandler(TextOutputWorkItem.NAME, <font color="navy"><b>new</b></font> TextOutputWorkItem());
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ksession.getWorkItemManager().registerWorkItemHandler(ImageOutputWorkItem.NAME, <font color="navy"><b>new</b></font> ImageOutputWorkItem());
&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; String id = <font color="red">"blackdata"</font>;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Map&lt;String, Object&gt; params = <font color="navy"><b>new</b></font> HashMap&lt;String, Object&gt;();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; params.put(<font color="red">"id"</font>, id);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; process = ksession.startProcess(<font color="red">"de.toni.new"</font>, params);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; logger.dispose();
&#160;&#160;&#160; <font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My jBPM-Process only contains my own WorkItems. The process works great and all.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In my process I have some process variables like:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;property id="image" itemSubjectRef="_imageItem"/&gt;</span>
<span class="jive-xml-tag">&lt;property id="text" itemSubjectRef="_textItem"/&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>That I read and edit in my WorkItems:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">String text = (String) workItem.getParameter(<font color="red">"text"</font>);
&#160;
Map&lt;String, Object&gt; results = <font color="navy"><b>new</b></font> HashMap&lt;String, Object&gt;();
results.put(<font color="red">"text"</font>, text);
manager.completeWorkItem(workItem.getId(), results);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The problem is, that these variables are in the process and not in the database. I thought, the persistence and serializable of all would save these in my db.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="text-decoration: underline;">So my question to you:</span></p><p>How can I get these variables out of the process in a db?</p><p>I hope you understand what I mean, if not, just ask. <span> :) </span></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/649727#649727">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>