We are running GrailsHibernateUtil.unwrapIfProxy(obj) . He wonβt get rid of the introduced Grails methods and such - only the Hibernate / GORM proxy server, but that should be enough.
edit :
- Sorry for the question, but did you declare your domain class as
implements Serializable ? - It could be something you add / enter into your class, e.g. Grails non-bug 6379 .
- This code fragment (got it here ) worked for me in
grails console on a small domain class:
.
import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil import com.somegroup.domain.* def loc = SomeDomainClass.get(1) loc = GrailsHibernateUtil.unwrapIfProxy(loc) ByteArrayOutputStream bos = new ByteArrayOutputStream() ObjectOutput out = new ObjectOutputStream(bos) out.writeObject(loc) byte[] yourBytes = bos.toByteArray()
Victor Sergienko
source share