这是我的模型类。当我修改我的spring项目时,它给出了这个错误 请求处理失败;嵌套异常是org.hibernate.type.SerializationException:无法反序列化。 我做了几个解决方案,但会给出同样的错误。任何人都可以找到导致这种错误的原因 这是我的模特班......
> import java.io.Serializable; import java.util.Date;
>
> import javax.persistence.Basic; import javax.persistence.Column;
> import javax.persistence.Entity; import javax.persistence.FetchType;
> import javax.persistence.GeneratedValue; import
> javax.persistence.GenerationType; import javax.persistence.Id; import
> javax.persistence.JoinColumn; import javax.persistence.ManyToOne;
> import javax.persistence.NamedQueries; import
> javax.persistence.NamedQuery; import
> javax.persistence.SequenceGenerator; import javax.persistence.Table;
> import javax.persistence.Temporal; import
> javax.persistence.TemporalType; import
> javax.xml.bind.annotation.XmlRootElement;
>
>
> @Entity @Table(name = "season_types" , schema = "unipointmain")
> @XmlRootElement @NamedQueries({
> @NamedQuery(name = "SeasonTypes.findAll", query = "SELECT s FROM SeasonTypes s"),
> @NamedQuery(name = "SeasonTypes.findBySeasonName", query = "SELECT s FROM SeasonTypes s WHERE s.seasonName = :seasonName"),
> @NamedQuery(name = "SeasonTypes.findBySeasonId", query = "SELECT s FROM SeasonTypes s WHERE s.seasonId = :seasonId"),
> @NamedQuery(name = "SeasonTypes.findByStartDate", query = "SELECT s FROM SeasonTypes s WHERE s.startDate = :startDate"),
> @NamedQuery(name = "SeasonTypes.findByEndDate", query = "SELECT s FROM SeasonTypes s WHERE s.endDate = :endDate"),
> @NamedQuery(name = "SeasonTypes.findByComment", query = "SELECT s FROM SeasonTypes s WHERE s.comment = :comment")}) public class
> SeasonTypes implements Serializable {
> private static final long serialVersionUID = 1L;
> @Column(name = "season_name")
> private String seasonName;
> @Id // @SequenceGenerator(name="pk_sequence",sequenceName="unipointmain.season_types_pk_seq",
> allocationSize=1)
> // @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="pk_sequence")
> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="season_types_pk_seq")
> @SequenceGenerator(name="season_types_pk_seq", sequenceName="unipointmain.season_types_pk_seq", allocationSize=1)
> @Column(name = "season_id")
> private Integer seasonId;
>
> @Column(name = "merchant_ref_id") private Merchant merchant;
> @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "merchant_ref_id")
> public Merchant getMerchant() { return merchant; } public void setMerchant(Merchant merchant) { this.merchant = merchant; }
>
> @Column(name = "start_date")
> private String startDate;
> @Column(name = "end_date")
> private String endDate;
> @Column(name = "comment")
> private String comment;
> @JoinColumn(name = "offer_id", referencedColumnName = "offerid")
> @ManyToOne
> private Offer offerId;
>
>
> public SeasonTypes() {
> }
> public SeasonTypes(Integer seasonId) {
> this.seasonId = seasonId;
> }
>
> public String getSeasonName() {
> return seasonName;
> }
>
> public void setSeasonName(String seasonName) {
> this.seasonName = seasonName;
> }
>
> public Integer getSeasonId() {
> return seasonId;
> }
>
> public void setSeasonId(Integer seasonId) {
> this.seasonId = seasonId;
> }
>
> public String getStartDate() {
> return startDate;
> }
>
> public void setStartDate(String startDate) {
> this.startDate = startDate;
> }
>
> public String getEndDate() {
> return endDate;
> }
>
> public void setEndDate(String endDate) {
> this.endDate = endDate;
> }
>
> public String getComment() {
> return comment;
> }
>
> public void setComment(String comment) {
> this.comment = comment;
> }
>
> public Offer getOfferId() {
> return offerId;
> }
>
> public void setOfferId(Offer offerId) {
> this.offerId = offerId;
> }
>
> @Override
> public int hashCode() {
> int hash = 0;
> hash += (seasonId != null ? seasonId.hashCode() : 0);
> return hash;
> }
>
> @Override
> public boolean equals(Object object) {
> // TODO: Warning - this method won't work in the case the id fields are not set
> if (!(object instanceof SeasonTypes)) {
> return false;
> }
> SeasonTypes other = (SeasonTypes) object;
> if ((this.seasonId == null && other.seasonId != null) || (this.seasonId != null && !this.seasonId.equals(other.seasonId))) {
> return false;
> }
> return true;
> }
>
> @Override
> public String toString() {
> return "com.unipoint.test.SeasonTypes[ seasonId=" + seasonId + " ]";
> }
>
> }
答案 0 :(得分:1)
您的类必须是可序列化的,以及作为您的类的参数提供的任何类。
您的问题可能是Merchant
或Offer
没有实现可序列化的界面。
希望这有帮助