Reputation: 15018
I am trying to persist a Groovy Closure (which are allegedly serializable) as a property of one of my Grails domain objects. Currently I'm basically doing this:
class MyClass {
....
Closure myClosure
static mapping = { myClosure size: 1024 * 1024, type: 'blob' }
}
new MyClass(myClosure: { ... do some stuff .. }.dehydrate()).save()
I tried changing 'blob' to 'binary' but that doesn't work. I get an error similar to: context.GrailsContextLoader Error executing bootstraps: BootStrap$_obj_closure3 cannot be cast to java.sql.Blob
How should I set up my domain object in order to be able to store a closure?
I am using Grails 2.1.1 with Groovy 2.0
Upvotes: 2
Views: 833
Reputation: 15018
I needed this:
static mapping = {
myClosure sqlType: 'blob'
}
Upvotes: 3