<!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="http://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;">
    Storing long String (>255 Characters) in Process Variables is not Possible(?)
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/k0k0pelli">Silvio Meier</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/595635#595635">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I&rsquo;m currently working on a process containing a mail task with JBPM 4.4. I need to generate a localized&#160; mail using a preferred language (either German or English). My first approach was to use a separate mail template for each language and then to set the corresponding template by using an expression within the process definition. However, this approach did not succeed, as the process definition could not be deployed because no expressions are allowed in the reference to the mail template. Thus, I had to discard this solution. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Instead I&rsquo;m currently using a set of variables that are finally used to compose the mail in the template using expression. Nevertheless, some of the text parts are longer than 255 characters, so I cannot use simple strings to be stored as process variables because it results in a data truncation exception thrown by the jdbc driver.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I found out that it should be possible to store a string that is longer than 255 characters by converting it to a char array. jBPM should handle these char[] variables as long text fields in the data base (hibernate type &ldquo;text&#8221;). </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>However, this seems also not to work, because the internal representation (class org.jbpm.pvm.internal.type.variable.TextVariable) of the char array uses a char[] which is directly passed to hibernate as is. On the other hand, the internal hibernate representation of a long text field (org.hibernate.type.TextType) expects a String object for a text field. This leads to the following exception when trying to store the char[] variable:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Caused by: java.lang.ClassCastException: [C cannot be cast to java.lang.String</p><p>&#160;&#160;&#160; at org.hibernate.type.TextType.toString(TextType.java:94)</p><p>&#160;&#160;&#160; at org.hibernate.type.NullableType.nullSafeToString(NullableType.java:117)</p><p>&#160;&#160;&#160; at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:158)</p><p>&#160;&#160;&#160; at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:131)</p><p>&#160;&#160;&#160; at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2015)</p><p>&#160;&#160;&#160; at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2261)</p><p>&#160;&#160;&#160; at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678)</p><p>&#160;&#160;&#160; at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)</p><p>&#160;&#160;&#160; at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)</p><p>&#160;&#160;&#160; at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)</p><p>&#160;&#160;&#160; at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)</p><p>&#160;&#160;&#160; at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)</p><p>&#160;&#160;&#160; at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)</p><p>&#160;&#160;&#160; at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)</p><p>&#160;&#160;&#160; at org.jbpm.pvm.internal.tx.HibernateSessionResource.prepare(HibernateSessionResource.java:56)</p><p>&#160;&#160;&#160; at org.jbpm.pvm.internal.tx.StandardTransaction.commit(StandardTransaction.java:107)</p><p>&#160;&#160;&#160; at org.jbpm.pvm.internal.tx.StandardTransaction.complete(StandardTransaction.java:64)</p><p>&#160;&#160;&#160; at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:57)</p><p>&#160;&#160;&#160; at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)</p><p>&#160;&#160;&#160; at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)</p><p>&#160;&#160;&#160; at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56)</p><p>&#160;&#160;&#160; at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)</p><p>&#160;&#160;&#160; at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.createVariables(ExecutionServiceImpl.java:174)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I think the only way to get it work for character arrays is to implement a converter (org.jbpm.pvm.internal.type.Converter), which is registered in the xml file jbpm.variable.types.xml, and to adapt the isStorable(Object ) method in the type org.jbpm.pvm.internal.type.variable.TextVariable.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Are there any other (simpler) suggestions to work around this problem?</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/595635#595635">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://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>