-
1. Re: Variables types / String too large for column
mwohlf Aug 7, 2010 10:17 AM (in response to charles_a)the following hackery stores a variable in the TEXT_VALUE_ column of JBPM4_VARIABLE:
EnvironmentImpl environment = processEngine.openEnvironment();
try {
taskImpl.createVariable("varName", "a real long text value here".toCharArray(), "char[]", false);
} finally {
environment.close();
}HTH
Michael
-
2. Re: Variables types / String too large for column
charles_a Aug 9, 2010 3:52 AM (in response to mwohlf)Hi Michael,
I´ll give it a try. But as you say, this also is a hack. But I think a better hack than our container object hack
Are there any plans to improve the "variable type handling" in jbpm? As stated in my initial post, we also had trouble with hibernate objects that we would like to handle as simple serializable objects. Sometimes it would be helpful to define the type manually or have more control in some way. Is there anything in jira around this topic?
Cheers,
Charles
-
3. Re: Variables types / String too large for column
rebody Aug 9, 2010 4:01 AM (in response to charles_a)Hi Charles,
Please try this codes:
executionService.setVariable("largeString", largeString.toCharArray());
or
executionService.setVariable("blob", largeString.getBytes("UTF-8"));
-
4. Re: Variables types / String too large for column
charles_a Aug 9, 2010 7:31 AM (in response to rebody)Hi Huisheng,
looks even better. But with this (and Michaels) way, we´re unable to use the String value of the variable in expression language. For example, if we store a lot of users comma separated in this variable and want them to receive a mail, we get a ClassCastException as char[] is not a subclass of String.
Probably we´ll stick with our container object, because here we can simple use the getter to receive the String in expression language, i. e. ${myvar.value}. Not nice, but works.
Huisheng, any ideas how to tweak jbpm to get the char[] working in EL like a regular String variable?
Cheers,
Charles
-
5. Re: Variables types / String too large for column
rebody Aug 9, 2010 8:32 AM (in response to charles_a)Actually, there is no easy way to convert char[] to string. You must create a bean a export this bean to the jbpm.cfg.xml, like <object name="myConverterBean" class="my.converterBean"/>, then use this bean to convert char[] to String. like #{myConverterBean.convert(charArray)}.
Hmm~, I see. Seems we should provide a way to auto-detect how to store long string.
-
6. Re: Variables types / String too large for column
charles_a Aug 9, 2010 9:20 AM (in response to rebody)One thing to keep in mind is, that users may be querying the database directly. If it´s stored in the one or another column based on the length of the string... it could be confusing. That´s why I would propose to explicitly define if it should be stored as a "long" or "short" string.
Charles