報錯現(xiàn)象
Oops: JPAQueryException
An unexpected error occured caused by exception JPAQueryException: Error while executing query select t from TurnedIn t, Notification n where n.itemId=t.id and n.type=? and n.receiver.id=? and n.isDeleted=false group by t order by t.createTime desc: org.hibernate.type.SerializationException: could not deserialize
...
Caused by: java.io.InvalidClassException: models.member.Member; local class incompatible: stream classdesc serialVersionUID = 8996579512119659486, local class serialVersionUID = -7513555048418418149An unexpected error occured caused by exception JPAQueryException: Error while executing query select t from TurnedIn t, Notification n where n.itemId=t.id and n.type=? and n.receiver.id=? and n.isDeleted=false group by t order by t.createTime desc: org.hibernate.type.SerializationException: could not deserialize
...
異常原因
本地和遠程的member序列化后的serialVersionUID不
解決方法
將本地的序列化的類中的版本號(serialVersionUID )改成和遠程中一樣,在本地的序列化類里的private static final long serialVersionUID = 改成遠程的就行了,如果沒有的話就加上這句。
關(guān)于“org.hibernate.type.SerializationException: could not deserialize”,我查了很多的資料,大概有以下幾個原因:
1.該類的序列版本號與從流中讀取的類描述符的版本號不匹配(jdk版本更換會造成這個問題)
2.該類包含未知數(shù)據(jù)類型(hibernate配置文件中未指定數(shù)據(jù)類型)
3.該類沒有可訪問的無參數(shù)構(gòu)造方法