问题描述
异常:org.hibernate.type.SerializationException:couldnotdeserializeatorg.hibernate.util.SerializationHelper.doDeserialize(SerializationHelper.java:262)atorg.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:306)atorg.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:130)atorg.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:116)atorg.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:39)atorg.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:62)atorg.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)atorg.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)atorg.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:249)atorg.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:229)atorg.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:330)atorg.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2265)atorg.hibernate.loader.Loader.loadFromResultSet(Loader.java:1527)atorg.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1455)atorg.hibernate.loader.Loader.getRow(Loader.java:1355)atorg.hibernate.loader.Loader.getRowFromResultSet(Loader.java:611)atorg.hibernate.loader.Loader.doQuery(Loader.java:829)atorg.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)atorg.hibernate.loader.Loader.loadEntity(Loader.java:2037)atorg.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)atorg.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)atorg.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3268)atorg.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)atorg.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)atorg.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)atorg.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:147)atorg.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1091)atorg.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1027)atorg.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:176)atorg.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)atorg.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)atcode.StdInfo_$$_javassist_0.getEmail(StdInfo_$$_javassist_0.java)attest.HibernateTest.insert3(HibernateTest.java:82)attest.HibernateTest.testInsert(HibernateTest.java:98)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atjunit.framework.TestCase.runTest(TestCase.java:168)atjunit.framework.TestCase.runBare(TestCase.java:134)atjunit.framework.TestResult$1.protect(TestResult.java:110)atjunit.framework.TestResult.runProtected(TestResult.java:128)atjunit.framework.TestResult.run(TestResult.java:113)atjunit.framework.TestCase.run(TestCase.java:124)atjunit.framework.TestSuite.runTest(TestSuite.java:232)atjunit.framework.TestSuite.run(TestSuite.java:227)atorg.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)atorg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)atorg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Causedby:java.io.StreamCorruptedException:invalidstreamheader:313B323Batjava.io.ObjectInputStream.readStreamHeader(UnknownSource)atjava.io.ObjectInputStream.<init>(UnknownSource)atorg.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:328)atorg.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:318)atorg.hibernate.util.SerializationHelper.doDeserialize(SerializationHelper.java:237)...52morehbm.xml<hibernate-mapping><classname="code.StdInfo"table="std_info"catalog="sample"><idname="id"type="string"><columnname="id"length="32"/><generatorclass="uuid.hex"/></id><propertyname="name"type="string"><columnname="name"length="100"/></property><propertyname="age"type="int"><columnname="age"not-null="true"/></property><propertyname="email"type="test.StdType"><columnname="email"/></property></class></hibernate-mapping>类publicclassStdTypeimplementsType,Serializable{privateListemails;privatestaticfinalchartempChar=';';privatestaticfinalint[]types={Types.VARCHAR};@Overridepublicint[]sqlTypes(){//TODOAuto-generatedmethodstubreturntypes;}@OverridepublicClassreturnedClass(){//TODOAuto-generatedmethodstubreturnList.class;}@Overridepublicbooleanequals(Objecta,Objectb){//TODOAuto-generatedmethodstubif(a==b){returntrue;}elseif(a!=null&&b!=null){ListaList=(List)a;ListbList=(List)b;if(aList.size()!=bList.size()){returnfalse;}else{intsize=aList.size();for(inti=0;i<size;i++){StringaString=(String)aList.get(i);StringbString=(String)bList.get(i);if(!aString.equals(bString)){returnfalse;}}returntrue;}}else{returnfalse;}}@OverridepublicObjectnullSafeGet(ResultSetrs,String[]name,Objectowner)throwsHibernateException,SQLException{//TODOAuto-generatedmethodstubStringvalue=null;value=(String)Hibernate.STRING.nullSafeGet(rs,name[0]);if(value!=null){returnparse(value);}else{returnnull;}}@OverridepublicvoidnullSafeSet(PreparedStatementst,Objectvalue,intindex)throwsHibernateException,SQLException{//TODOAuto-generatedmethodstubif(value!=null){Stringstr=assemble((List)value);Hibernate.STRING.nullSafeSet(st,str,index);}else{}}@OverridepublicObjectdeepCopy(Objectvalue){//TODOAuto-generatedmethodstubListsource=(List)value;Listcopy=newArrayList();copy.addAll(source);returncopy;}@OverridepublicbooleanisMutable(){//TODOAuto-generatedmethodstubreturnfalse;}privateListparse(Stringvalue){ArrayList<String>list=newArrayList<String>();intstartIndex=0;intindex=-1;do{index=value.indexOf(tempChar,startIndex);if(index!=-1){list.add(value.substring(startIndex,index));startIndex=index+1;}else{list.add(value.substring(startIndex));}}while(index!=-1);returnlist;}privateStringassemble(Listlist){StringBufferbuffer=newStringBuffer();for(inti=0;i<list.size();i++){buffer.append((String)list.get(i));if(i<list.size()-1){buffer.append(tempChar);}}returnbuffer.toString();}}
解决方案
解决方案二:
这就不懂了?是不是还有没实现的然后互相调用了?
解决方案三:
引用1楼dyllove98的回复:
这就不懂了?是不是还有没实现的然后互相调用了?
什么意思?
解决方案四:
没有人知道吗?
解决方案五:
该回复于2010-11-26 13:08:54被版主删除
解决方案六:
问题看的不是很明白<propertyname="email"type="test.StdType"><columnname="email"/></property>StdType是你自定义的类型吧,如果StdType是一个对象类型,那这个得用many-to-0ne
解决方案七:
<many-to-onename="email"class="test.StdType"><columnname="EMP_email_ID"/></many-to-one>试试看吧,序列化器里面是怎么写的能否贴出来看看
解决方案八:
该回复于2010-12-08 09:49:58被版主删除
解决方案九:
不懂,看来我还得好好的修炼啊