Question

I'm using GWT, Hibernate and Gilead and I do not get rid of the serialization exception:

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.

I'm doing a JOIN in the Hibernate Query Language which causes the error:

List<UserEvent> userEvents = session.createQuery(
    "FROM UserEvent as userevent JOIN userevent.event as event WHERE userevent.user = ? AND userevent.status = 'JOIN' ORDER BY event.eventBegin ASC")
    .setLong(0, user.getUserID()).setFirstResult(start).setMaxResults(maxResult).list();

the code for the classes are:

@Entity
public class UserEvent extends LightEntity implements Serializable {

    private static final long serialVersionUID = -291120580889352994L;

    @Id
    @ManyToOne
    @JoinColumn(name = "user_userid")
    private User user;

    @Id
    @ManyToOne
    @JoinColumn(name = "event_eventid")
    private Event event;

    @Enumerated(EnumType.STRING)
    private EventStatus status;

    private Long time;

    public UserEvent() {

    }



@Entity
public class Event extends LightEntity implements Serializable {

    private static final long serialVersionUID = -2504468186803850440L;

    @Id
    @GenericGenerator(name = "event_seq", strategy = "webapp.hibernate.EventSeq")
    @GeneratedValue(generator = "event_seq")
    private Long eventID;

    private Long eventBegin;

    public Event() {

    }

Does anybody knows a solution for this?

No correct solution

OTHER TIPS

The problem you're seeing here is due to the fact that the object that gets loaded by the

query.list()

call is not loading UserEvents. It is loading a dynamic proxy of the UserEvent. Hibernate uses proxy objects to intercept calls to lazy loaded related objects.

There are libraries out there that can help with this (EG http://www.jboss.org/errai).

Another thing you can do is convert your JPA entities to POJOs before attempting to serialise them, which should ensure the proxies don't get in the way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top