I have a class Data which implements Serializable interface. This class has such fields
private boolean q = false;
private String a = "";
private List<Someclass> m = Collections.emptyList();
private List<Object[]> d = Collections.emptyList();
Values assigned to these members are default values. Class Someclass also implements Serializable and it has such columns
private Types sqlType;
private int columnWidth;
private String columnName;
Types is an enum which also implements serializable.
In Data class I have List<Object[]> d in which I will save data fethced from database through jdbc(when iterating ResultSet i use getObject() method). I use such construction, because it can run any query(query’s structure is not known). In List<Someclass> m I hold metada of query. So when I try to fetch rows with simple query I get
com.google.gwt.user.client.rpc.SerializationException: Type '[Ljava.lang.Object;' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = [Ljava.lang.Object;@127053a9
Why it occures? All my transfer objects are serializable.
edit
Ok, Object is not Serializable so it can not be passed to and returned from the server. But what I should use in this case. Generics will not help me, because I don’t know the type at compile time
In order for the class to be serializable, essentially everything you can get to from it has to also be serializable. In this case Object is not serializable, which makes Object[] not serializable, which makes List not serializable, which makes Data not serializable.
Think about it this way: If you can’t serialize a given Object in the Object[], how are you going to serialize the Object[]? And if you can’t serialize that, how are you going to serialize a list of that? And if you can’t serialize that list, how are you going to serialize something that contains that list?
Now, it could be that everything in your Object[] ends up being serializable — but the way you’ve typed it, the compiler can’t guarantee that.
EDIT: Regarding what you should use instead, I would create some sort of wrapper class that will hold the SQL query’s results, and make that one serializable.