GWT exception "Cannot Serialize" when using Hibernate -
i'm getting "com.google.gwt.user.client.rpc.serializationexception:", when employing gwt+hibernate. tried google, of error in context of list (i found similiar thread here gwt cannot serialize object hibernate). i'm getting when i'm trying pass object of type userpreference through rpc. below classes reference.
public class userpreference implements serializable { private static final long serialversionuid = 1l; private userinfo userinfo; // other attributes public userpreference() { super(); } // getters/setters }
// userinfo class
public class userinfo implements serializable{ private int id; private string name; private string cuid; private userrole role; private dbschema favdb; public userinfo() { super(); } }
//dbschema class
public class dbschema implements serializable{ private static final long serialversionuid = 1l; private int id; private string name; private int port; private string host; private string sidname; private string username; private string password; private string defaultconfigid; public dbschema() { super(); } //getters/setters }
i don't know problem 'dbschema' class. data being retrieved fine db, , when make dbschema instance 'transient' in userinfo class, working fine. didn't try dozer or gilead, want know actual issue code.
thanks help.
you have problem because hibernate lazy fetching referenced objects: when userinfo object created hibernate, favdb
not pointing actual dbschema
object hibernate-generated proxy (this implemented via getter/setter not field itself).
a general solution create dto (data transfer object). see blogpost explanation , solution: http://hibernate4gwt.sourceforge.net/hibernate_gwt_lazy_issue.html
Comments
Post a Comment