[jboss-user] [jBPM] - Storing long String (>255 Characters) in Process Variables is not Possible(?)

Silvio Meier do-not-reply at jboss.com
Fri Mar 25 13:04:37 EDT 2011


Silvio Meier [http://community.jboss.org/people/k0k0pelli] created the discussion

"Storing long String (>255 Characters) in Process Variables is not Possible(?)"

To view the discussion, visit: http://community.jboss.org/message/595635#595635

--------------------------------------------------------------
I’m currently working on a process containing a mail task with JBPM 4.4. I need to generate a localized  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. 

Instead I’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.

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 “text”). 

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:

Caused by: java.lang.ClassCastException: [C cannot be cast to java.lang.String
    at org.hibernate.type.TextType.toString(TextType.java:94)
    at org.hibernate.type.NullableType.nullSafeToString(NullableType.java:117)
    at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:158)
    at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:131)
    at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2015)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2261)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678)
    at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
    at org.jbpm.pvm.internal.tx.HibernateSessionResource.prepare(HibernateSessionResource.java:56)
    at org.jbpm.pvm.internal.tx.StandardTransaction.commit(StandardTransaction.java:107)
    at org.jbpm.pvm.internal.tx.StandardTransaction.complete(StandardTransaction.java:64)
    at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:57)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
    at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56)
    at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
    at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.createVariables(ExecutionServiceImpl.java:174)

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.

Are there any other (simpler) suggestions to work around this problem?
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/595635#595635]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110325/dd466df1/attachment.html 


More information about the jboss-user mailing list