may i use domain (gorm - JPA-Entities) classes in process variables?

252 views
Skip to first unread message

Necip AKCA

unread,
Oct 19, 2012, 7:54:22 AM10/19/12
to grails-acti...@googlegroups.com
hi all,
I am newbie in grails and activiti.
I try to use my domain class in process and,  i could not solve problems like

couldn't find a variable type that is able to serialize [id:ff8080813a78d0a7013a78d0c7230000]

or deserialization problems...

just  i have changed the type of employename to User type instead of String in Vocation request example. I have search for JPA-Entities i found 


but this is for spring entity class not like GORM. 

Do some one have any experience about using GORM classes as a process variable type ?? I could not find any example about that.

i have built my site on grails 2.1.1, activiti 5.9 and spring-security-core.  

Thanks for any advise,
Best Regards.

Chee Kin Lim

unread,
Oct 28, 2012, 8:42:50 AM10/28/12
to grails-acti...@googlegroups.com
Hi there,

Thanks for using the plugin and sorry for slow response.

I think it is possible to store GORM instance in process variable as the Issue #16 at http://code.google.com/p/grails-activiti-plugin/issues/detail?id=16 fixed by Ilya.Drabenia at https://github.com/limcheekin/activiti/pull/1. This fix released in 5.9 which I overlook. I just update the release history of 5.9 to reflect this.

You might want to look into detail on how she did it at https://github.com/limcheekin/activiti/commit/00bb93177dddde636c593c7a8da7f4894978717b

Hope this help.

Best regards,
Chee Kin





--
 
 
 

Andy

unread,
Dec 19, 2012, 2:53:47 PM12/19/12
to grails-acti...@googlegroups.com
While the fix by Ilya.Drabenia does fix the problem - it has a somewhat negative effect.

Since the customPreVariableType, SerializableVariableType is added first in the list of variable types, and because its 
isAbleToStore method returns true for ANY serializable type, including strings, dates, primitives and their object counterparts, almost ALL process variables get stored as type: "groovySerializable". This is somewhat irritating, since it is difficult to view the value in the database (they are stored as blobs in the ACT_GE_BYTEARRAY) table.

Using customPostVariableTypes isn't an option, since the out-of the-box serializable will still be chosen first. I made the following modification to SerializableVariableType.isAbleToStore() so that the appropriate type from the basic set is still invoked on basic types. Not elegant, but it works.

boolean isAbleToStore(Object value) {
if (value==null) {
return false;
}
Class theclass = value.getClass();
boolean isAssignable = (
byte[].class.isAssignableFrom(theclass)
|| String.class.isAssignableFrom(value.getClass())
|| Boolean.class.isAssignableFrom(value.getClass())
|| boolean.class.isAssignableFrom(value.getClass())
|| Short.class.isAssignableFrom(value.getClass())
|| short.class.isAssignableFrom(value.getClass())
|| Integer.class.isAssignableFrom(value.getClass())
|| int.class.isAssignableFrom(value.getClass())
|| Long.class.isAssignableFrom(value.getClass())
|| long.class.isAssignableFrom(value.getClass())
|| Date.class.isAssignableFrom(value.getClass())
|| Double.class.isAssignableFrom(value.getClass())
|| ItemInstance.class.isAssignableFrom(theclass)
|| MessageInstance.class.isAssignableFrom(theclass)
);
return (!isAssignable && value instanceof Serializable);
}

Chee Kin Lim

unread,
Dec 20, 2012, 8:55:28 AM12/20/12
to grails-acti...@googlegroups.com
Hi Andy,

Thanks for sharing the solution.

Best regards,
Chee Kin




--
 
 
 

Reply all
Reply to author
Forward
0 new messages