-->
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.  [ 1 post ] 
Author Message
 Post subject: could not deserialize error Q
PostPosted: Wed May 30, 2007 4:55 pm 
Newbie

Joined: Mon Apr 09, 2007 10:46 am
Posts: 5
I am trying to map a many-to-many relationship using a composite-id in the association table. Following examples from here and various books, I'm close.

The association table's columns are filled correctly when linking and saving the objects. I can also load objects from either end of the relationship.

My trouble is I get an "Unable to deserialize" message when loading the association table. I'm requesting suggestions on what I need to fix because it looks right to me.

Misc Info
Running the SQL by hand produces the desired results.

The three classes are Serializable and implement hashCode() and equals() methods.

Objective ---- * ObjectiveMeasure *---- Measure

I am using the Oracle drive from their classes12.jar file which I suppose may be suspect.


Hibernate version: 3.2

Mapping documents:
Code:
<hibernate-mapping>
    <class
        name="model.ObjectiveMeasure"
        table="IPP_OBJ_MSR"
        lazy="false"
    >

        <composite-id name="id" class="model.ObjectiveMeasure$ObjectiveMeasureId">
            <key-property name="measure" type="model.Measure" column="MEASURE_ID" />
         <key-property name="objective" type="model.Objective" column="OBJ_ID" />
      </composite-id>
      
        <many-to-one
            name="measure"
            class="model.Measure"
            cascade="none"
            outer-join="auto"
            update="false"
            insert="false"
            column="MEASURE_ID"
            not-null="false"
        />

        <many-to-one
            name="objective"
            class="model.Objective"
            cascade="none"
            outer-join="auto"
            update="false"
            insert="false"
            column="OBJ_ID"
            not-null="false"
        />

        <property
            name="relationship"
            type="java.lang.String"
            update="true"
            insert="true"
            column="RELATIONSHIP"
            length="10"
            not-null="false"
        />
    </class>
</hibernate-mapping>


<hibernate-mapping>
    <class
        name="model.Measure"
        table="IPP_MEASURE"
        lazy="false"
    >
        <id
            name="id"
            column="ID"
            type="long"
            unsaved-value="0"
        >
            <generator class="native">
                <param name="sequence">ipp_ic_measure_seq</param>
            </generator>
        </id>

      <bag
            name="objectives"
            table="IPP_OBJ_MSR"
            lazy="false"
            inverse="true"
            cascade="save-update"
        >
            <key
                column="MEASURE_ID"
            >
            </key>

            <many-to-many
                class="model.Objective"
                column="OBJ_ID"
                outer-join="auto"
             />
      </bag>
</class>
</hibernate-mapping>

<hibernate-mapping>
    <class
        name="model.Objective"
        table="IPP_OBJECTIVE"
        lazy="false"
    >
        <id
            name="id"
            column="ID"
            type="long"
            unsaved-value="0"
        >
            <generator class="native">
                <param name="sequence">ipp_objective_seq</param>
            </generator>
        </id>

        <bag
            name="measures"
            table="IPP_OBJ_MSR"
            lazy="false"
            inverse="false"
            cascade="save-update"
        >
            <key
                column="OBJ_ID"
            >
            </key>

            <many-to-many
                class="model.Measure"
                column="MEASURE_ID"
                outer-join="auto"
             />
      </bag>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

session.createQuery( "from ObjectiveMeasure" ).list();

Full stack trace of any exception that occurs:
Code:
The debug output:

15:05:40,834 DEBUG SQL:393 -
    select
        objectivei0_.MEASURE_ID as IC1_16_,
        objectivei0_.OBJ_ID as OBJ2_16_,
        objectivei0_.RELATIONSHIP as RELATION3_16_
    from
        ipp.IPP_OBJ_MSR objectivei0_
Hibernate:
    select
        objectivei0_.MEASURE_ID as IC1_16_,
        objectivei0_.OBJ_ID as OBJ2_16_,
        objectivei0_.RELATIONSHIP as RELATION3_16_
    from
        ipp.IPP_OBJ_MSR objectivei0_
15:05:40,834 DEBUG AbstractBatcher:476 - preparing statement
15:05:41,084 DEBUG AbstractBatcher:374 - about to open ResultSet (open ResultSets: 0, globally: 0)
15:05:41,084 DEBUG Loader:682 - processing result set
15:05:41,084 DEBUG Loader:687 - result set row: 0
15:05:41,100 DEBUG SerializationHelper:204 - Starting deserialization of object
15:05:41,100  INFO SerializableType:128 - could not read column value from result set: IC1_16_; could not deserialize
15:05:41,100 DEBUG AbstractBatcher:381 - about to close ResultSet (open ResultSets: 1, globally: 1)
15:05:41,100 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
15:05:41,100 DEBUG AbstractBatcher:525 - closing statement
15:05:41,100 DEBUG JDBCContext:233 - after autocommit
15:05:41,100 DEBUG ConnectionManager:398 - aggressively releasing JDBC connection
15:05:41,100 DEBUG ConnectionManager:435 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
15:05:41,100 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
org.hibernate.type.SerializationException: could not deserialize
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:217)
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:240)
   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:113)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
   at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
   at org.hibernate.type.ComponentType.hydrate(ComponentType.java:560)
   at org.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:275)
   at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1088)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:553)
   at org.hibernate.loader.Loader.doQuery(Loader.java:689)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
   at org.hibernate.loader.Loader.doList(Loader.java:2144)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
   at org.hibernate.loader.Loader.list(Loader.java:2023)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
   at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
   at model.ObjectiveMeasureTestDB.findObjectiveMeasure(ObjectiveMeasureTestDB.java:106)
   at model.ObjectiveMeasureTestDB.testHashCode(ObjectiveMeasureTestDB.java:80)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.io.StreamCorruptedException: invalid stream header
   at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:763)
   at java.io.ObjectInputStream.<init>(ObjectInputStream.java:278)
   at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:252)
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:209)
   ... 40 more


Name and version of the database you are using: Oracle 10.1g

The generated SQL (show_sql=true):
15:05:40,834 DEBUG SQL:393 -
select
objectivei0_.MEASURE_ID as IC1_16_,
objectivei0_.OBJ_ID as OBJ2_16_,
objectivei0_.RELATIONSHIP as RELATION3_16_
from
ipp.IPP_OBJ_MSR objectivei0_
Hibernate:
select
objectivei0_.MEASURE_ID as IC1_16_,
objectivei0_.OBJ_ID as OBJ2_16_,
objectivei0_.RELATIONSHIP as RELATION3_16_
from
ipp.IPP_OBJ_MSR objectivei0_

Debug level Hibernate log excerpt: debug

POJO Code Snippets
equals() and hashCode() are implemented on all classes.

Code:
public class Measure implements java.io.Serializable
{
   private List<Objective> objectives;
   
   public long getId() ...
   public List<Objective> getObjectives() ...
}


public class Objective implements java.io.Serializable
{
   private Measure measure;
   
   public long getId() ...
   public List<IcMeasure> getIcMeasures() ...
}

public class ObjectiveMeasure implements java.io.Serializable
{
   private Measure measure;
   private Objective objective;
   
   public Measure getMeasure() ...
   public Objective getObjective() ...
   public String getRelationship() ...


   public static class ObjectiveMeasureId implements java.io.Serializable
   {
      private Measure icm;
      private Objective obj;
      
      public Measure getMeasure() ...
      public Objective getObjective() ...
   }
}


[/code]


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

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.