在是用HQL语言查询的过程中出现如下错误:
org.hibernate.type.SerializationException: could not deserialize
Caused by: java.io.StreamCorruptedException: invalid stream header: 32003000
估计是在映射文件,实体类和数据库表中出错,但不找不出什么原因........H

解决方案 »

  1.   

    把你的代码详细代码发过来。
    可能触发的原因:
    1,ORM映射,你的hibernate映射文件里面的是否和你实体类对应,表的字段是否对应。
    2,实体类是否序列化。
      

  2.   


    //Post.java
    @Entity
    @Table(name = "posts", schema = "dbo", catalog = "JavaSystem")
    public class Posts implements java.io.Serializable { private int pid;
    private String ptitle;
    private String pauther;
    private Serializable pdate;
    private Set<Replys> replyses = new HashSet<Replys>(0); public Posts() {
    } public Posts(int pid) {
    this.pid = pid;
    } public Posts(int pid, String ptitle, String pauther, Serializable pdate,
    Set<Replys> replyses) {
    this.pid = pid;
    this.ptitle = ptitle;
    this.pauther = pauther;
    this.pdate = pdate;
    this.replyses = replyses;
    } @Id
    @Column(name = "pid", unique = true, nullable = false)
    public int getPid() {
    return this.pid;
    } public void setPid(int pid) {
    this.pid = pid;
    } @Column(name = "ptitle")
    public String getPtitle() {
    return this.ptitle;
    } public void setPtitle(String ptitle) {
    this.ptitle = ptitle;
    } @Column(name = "pauther", length = 20)
    public String getPauther() {
    return this.pauther;
    } public void setPauther(String pauther) {
    this.pauther = pauther;
    } @Column(name = "pdate")
    public Serializable getPdate() {
    return this.pdate;
    } public void setPdate(Serializable pdate) {
    this.pdate = pdate;
    } @OneToMany(fetch = FetchType.LAZY, mappedBy = "posts")
    public Set<Replys> getReplyses() {
    return this.replyses;
    } public void setReplyses(Set<Replys> replyses) {
    this.replyses = replyses;
    }}
    //Replys.java
    @Entity
    @Table(name = "replys", schema = "dbo", catalog = "JavaSystem")
    public class Replys implements java.io.Serializable { private int replyid;
    private Posts posts;
    private String rcont;
    private String rauther;
    private Serializable rdate; public Replys() {
    } public Replys(int replyid) {
    this.replyid = replyid;
    } public Replys(int replyid, Posts posts, String rcont, String rauther,
    Serializable rdate) {
    this.replyid = replyid;
    this.posts = posts;
    this.rcont = rcont;
    this.rauther = rauther;
    this.rdate = rdate;
    } @Id
    @Column(name = "replyid", unique = true, nullable = false)
    public int getReplyid() {
    return this.replyid;
    } public void setReplyid(int replyid) {
    this.replyid = replyid;
    } @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "pid")
    public Posts getPosts() {
    return this.posts;
    } public void setPosts(Posts posts) {
    this.posts = posts;
    } @Column(name = "rcont")
    public String getRcont() {
    return this.rcont;
    } public void setRcont(String rcont) {
    this.rcont = rcont;
    } @Column(name = "rauther", length = 10)
    public String getRauther() {
    return this.rauther;
    } public void setRauther(String rauther) {
    this.rauther = rauther;
    } @Column(name = "rdate")
    public Serializable getRdate() {
    return this.rdate;
    } public void setRdate(Serializable rdate) {
    this.rdate = rdate;
    }}
      

  3.   


    //Posts.hbm.xml
    <hibernate-mapping>
        <class name="com.guet.bean.Posts" table="posts" schema="dbo" catalog="JavaSystem">
            <id name="pid" type="int">
                <column name="pid" />
                <generator class="assigned" />
            </id>
            <property name="ptitle" type="string">
                <column name="ptitle" />
            </property>
            <property name="pauther" type="string">
                <column name="pauther" length="20" />
            </property>
            <property name="pdate" type="serializable">
                <column name="pdate" />
            </property>
            <set name="replyses" table="replys" inverse="true" lazy="true" fetch="select">
                <key>
                    <column name="pid" />
                </key>
                <one-to-many class="com.guet.bean.Replys" />
            </set>
        </class>
    </hibernate-mapping>//Replys.hbm.xml
    <hibernate-mapping>
        <class name="com.guet.bean.Replys" table="replys" schema="dbo" catalog="JavaSystem">
            <id name="replyid" type="int">
                <column name="replyid" />
                <generator class="assigned" />
            </id>
            <many-to-one name="posts" class="com.guet.bean.Posts" fetch="select">
                <column name="pid" />
            </many-to-one>
            <property name="rcont" type="string">
                <column name="rcont" />
            </property>
            <property name="rauther" type="string">
                <column name="rauther" length="10" />
            </property>
            <property name="rdate" type="serializable">
                <column name="rdate" />
            </property>
        </class>
    </hibernate-mapping>
      

  4.   

    posts表replys表
    replys表的pid为posts表pid的外键