-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Could not deserialize caused by invalid stream header
PostPosted: Thu Oct 19, 2006 9:17 am 
Newbie

Joined: Fri Jul 07, 2006 3:39 am
Posts: 4
My code:

I think that hbm.xml files are good.

TKitColaFichPdte.hbm.xml
Code:
<hibernate-mapping package="Hiber">

    <class name="TKitColaFichPdte" table="T_KIT_COLA_FICH_PDTE">
        <id name="kclCodigo" column="KCL_CODIGO" type="java.lang.Long"/>
       
      <property name="kclEstado" column="KCL_ESTADO" type="java.lang.String"  not-null="true" />
        <property name="kclLogCodigo" column="KCL_LOG_CODIGO" type="java.lang.Long"  not-null="true" />
        <property name="kclLogEstado" column="KCL_LOG_ESTADO" type="java.lang.String"  not-null="true" />
        <property name="kclLogNombre" column="KCL_LOG_NOMBRE" type="java.lang.String"  not-null="true" />      
      
      <many-to-one name="tKitPatron" class="TKitPatron" cascade="all" not-null="true">
         <column name="KCL_KPA_CODIGO"/>
         <column name="KCL_KAP_CODIGO"/>
      </many-to-one>
    </class>
   
</hibernate-mapping>


TKitPatron.hbm.xml
Code:
<hibernate-mapping package="Hiber">

    <class name="TKitPatron" table="T_KIT_PATRON">
        <composite-id name="id">
         <key-property name="kpaCodigo" column="KPA_CODIGO" type="java.lang.Long"/>
            <key-property name="kpaKapCodigo" column="KPA_KAP_CODIGO" type="Hiber.TKitProcesos"/>
        </composite-id>

        <property name="kpaPatron" column="KPA_PATRON" type="java.lang.String"  not-null="true" />
        <property name="kpaDescLarga" column="KPA_DESC_LARGA" type="java.lang.String"  not-null="true" />
        <property name="kpaUsuario" column="KPA_USUARIO" type="java.lang.String"  not-null="true" />
        <property name="kpaFecGrabacion" column="KPA_FEC_GRABACION" type="java.util.Date"  not-null="true" />
   
      <property name="tKitProcesos" column="KPR_CODIGO" type="Hiber.TKitProcesos"/>
        
      <set name="tKitColaFichPdteSet" inverse="true">
         <key>
            <column name="KCL_KPA_CODIGO"/>
               <column name="KCL_KAP_CODIGO"/>
            </key>

            <one-to-many class="TKitColaFichPdte"/>
        </set>
      
      <set name="tKitProcesos1" inverse="true">
            <key>
               <column name="KPR_CODIGO"/>
               <column name="KPA_KAP_CODIGO"/>
            </key>
           
            <one-to-many class="TKitProcesos"/>
        </set>
    </class>
</hibernate-mapping>


Java for TKitColaFichPdte
Code:
package Hiber;

import java.io.Serializable;

public abstract class AbstractTKitColaFichPdte
    implements Serializable
{
    private java.lang.Long kclCodigo;
    private TKitPatron tKitPatron;
    private java.lang.String kclEstado;
    private java.lang.Long kclLogCodigo;
    private java.lang.String kclLogEstado;
    private java.lang.String kclLogNombre;

    public AbstractTKitColaFichPdte()
    {
    }

    public AbstractTKitColaFichPdte(java.lang.Long kclCodigo)
    {
        this.setKclCodigo(kclCodigo);
    }

    /**
     * Return the simple primary key value that identifies this object.
     * @return java.lang.Long
     */
    public java.lang.Long getKclCodigo()
    {
        return kclCodigo;
    }

    /**
     * Set the simple primary key value that identifies this object.
     * @param kclCodigo
     */
    public void setKclCodigo(java.lang.Long kclCodigo)
    {
        this.hashValue = 0;
        this.kclCodigo = kclCodigo;
    }

    /**
     * Return the value of the KCL_ESTADO column.
     * @return java.lang.String
     */
    public java.lang.String getKclEstado()
    {
        return this.kclEstado;
    }

    /**
     * Set the value of the KCL_ESTADO column.
     * @param kclEstado
     */
    public void setKclEstado(java.lang.String kclEstado)
    {
        this.kclEstado = kclEstado;
    }

  /**
     * Return the value of the KCL_KPA_CODIGO column.
     * @return TKitPatron
     */
    public TKitPatron gettKitPatron()
    {
        return this.tKitPatron;
    }

    /**
     * Set the value of the KCL_KPA_CODIGO column.
     * @param tKitPatron
     */
    public void settKitPatron(TKitPatron tKitPatron)
    {
        this.tKitPatron = tKitPatron;
    }
   
    /**
     * Return the value of the KCL_LOG_CODIGO column.
     * @return java.lang.Long
     */
    public java.lang.Long getKclLogCodigo()
    {
        return this.kclLogCodigo;
    }

    /**
     * Set the value of the KCL_LOG_CODIGO column.
     * @param kclLogCodigo
     */
    public void setKclLogCodigo(java.lang.Long kclLogCodigo)
    {
        this.kclLogCodigo = kclLogCodigo;
    }

    /**
     * Return the value of the KCL_LOG_ESTADO column.
     * @return java.lang.String
     */
    public java.lang.String getKclLogEstado()
    {
        return this.kclLogEstado;
    }

    /**
     * Set the value of the KCL_LOG_ESTADO column.
     * @param kclLogEstado
     */
    public void setKclLogEstado(java.lang.String kclLogEstado)
    {
        this.kclLogEstado = kclLogEstado;
    }

    /**
     * Return the value of the KCL_LOG_NOMBRE column.
     * @return java.lang.String
     */
    public java.lang.String getKclLogNombre()
    {
        return this.kclLogNombre;
    }

    /**
     * Set the value of the KCL_LOG_NOMBRE column.
     * @param kclLogNombre
     */
    public void setKclLogNombre(java.lang.String kclLogNombre)
    {
        this.kclLogNombre = kclLogNombre;
    }
}


Java for TKitPatron
Code:
package Hiber;

import java.io.Serializable;

public abstract class AbstractTKitPatron
    implements Serializable
{
    private int hashValue = 0;
    private TKitPatronKey id;
    private java.util.Set tKitColaFichPdteSet;
    private java.lang.String kpaPatron;

    public AbstractTKitPatron()
    {
    }

    public AbstractTKitPatron(TKitPatronKey id)
    {
        this.setId(id);
    }

    /**
     * Return the composite id instance that identifies this object.
     * @return TKitPatronKey
     */
    public TKitPatronKey getId()
    {
        return this.id;
    }

    /**
     * Set the composite id instance that identifies this object.
     * @param id
     */
    public void setId(TKitPatronKey id)
    {
        this.hashValue = 0;
        this.id = id;
    }

    /**
     * Return the value of the KPA_PATRON column.
     * @return java.lang.String
     */
    public java.lang.String getKpaPatron()
    {
        return this.kpaPatron;
    }

    /**
     * Set the value of the KPA_PATRON column.
     * @param kpaPatron
     */
    public void setKpaPatron(java.lang.String kpaPatron)
    {
        this.kpaPatron = kpaPatron;
    }

    /**
     * Return the value of the KCL_KPA_CODIGO collection.
     * @return TKitColaFichPdte
     */
    public java.util.Set gettKitColaFichPdteSet()
    {
        return this.tKitColaFichPdteSet;
    }

    /**
     * Set the value of the KCL_KPA_CODIGO collection.
     * @param tKitColaFichPdteSet
     */
    public void settKitColaFichPdteSet(java.util.Set tKitColaFichPdteSet)
    {
        this.tKitColaFichPdteSet = tKitColaFichPdteSet;
    }
}


I want only see TKitFichPdte table with
Code:
private void mostrarFPdte(){
     Query query;
     Transaction tx;
     TKitColaFichPdte tkf;
     try {
        tx = session.beginTransaction();
        query = session.createQuery("from TKitColaFichPdte as b");
        for (Iterator iter = query.iterate(); iter.hasNext();){       
           tkf = (TKitColaFichPdte) iter.next();
           System.out.println("******** Column 1: " + tkf.getKclCodigo());
           System.out.println("******** Column 2: " + tkf.getKclEstado());
        }
        tx.commit();
     } catch (HibernateException e) {
        e.printStackTrace();
     }
  }


Error:
Code:
3749 [main] DEBUG org.hibernate.util.SerializationHelper  - Starting deserialization of object
3749 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to close ResultSet (open ResultSets: 2, globally: 2)
3749 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to close PreparedStatement (open PreparedStatements: 2, globally: 2)
3749 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - closing statement
org.hibernate.type.SerializationException: could not deserialize
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:211)
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:234)
   at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:78)
   at org.hibernate.type.SerializableType.get(SerializableType.java:39)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
   at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80)
   at org.hibernate.type.ComponentType.hydrate(ComponentType.java:423)
   at org.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:182)
   at org.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:84)
   at org.hibernate.persister.entity.BasicEntityPersister.hydrate(BasicEntityPersister.java:1690)
   at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:991)
   at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:942)
   at org.hibernate.loader.Loader.getRow(Loader.java:855)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:305)
   at org.hibernate.loader.Loader.doQuery(Loader.java:412)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
   at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
   at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
   at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
   at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
   at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
   at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
   at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:75)
   at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:643)
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
   at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
   at Hiber.TKitColaFichPdte$$EnhancerByCGLIB$$a8c38899.getKclEstado(<generated>)
   at Logica.TestGestionAPP.mostrarFPdte(TestGestionAPP.java:118)
   at Logica.TestGestionAPP.main(TestGestionAPP.java:177)
Caused by: java.io.StreamCorruptedException: invalid stream header
   at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:753)
   at java.io.ObjectInputStream.<init>(ObjectInputStream.java:268)
   at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:246)
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:203)
   ... 31 more


If i only show KclCodigo column work fine.

If i show other column appear error.

I think that AbstractTKitColaFichPdte dont work.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 4:34 am 
Newbie

Joined: Fri Jul 07, 2006 3:39 am
Posts: 4
Please. Someone can help me??


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 10:02 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Try to change mapping this way:
<property name="kclEstado" column="KCL_ESTADO" type="string"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 12:07 pm 
Newbie

Joined: Fri Jul 07, 2006 3:39 am
Posts: 4
It doesnt work.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 24, 2006 6:40 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Looks like property is mapped as "serializable" type:
"at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:78)"


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.