This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate + An exception occurred: org.hibernate.type.SerializationException

 
sonalika kulkarni
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I in our project we have a refactoring of package structure recently. Now the thing is that we have blobs in the table and templates that refer to earlier package structure. and now its giving SerializationException while reading blob which stores Serialized objects in it. What should be the best way to handle and update this exception?
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly why we need to use serialversionUid in our class when we are implementing serialization.
check how we can use serialver command in java. See if that helps.
 
sonalika kulkarni
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arun Kumarr wrote:That's exactly why we need to use serialversionUid in our class when we are implementing serialization.

how using serialversionUid can help us in serialization.
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value. It is also strongly advised that explicit serialVersionUID declarations use the private modifier where possible, since such declarations apply only to the immediately declaring class--serialVersionUID fields are not useful as inherited members." -- Serializable
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be this helps.
 
sonalika kulkarni
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the issue is that in my DB I have blob that refers to class location with some different classpath say "A.b.c.myclass.java" and after the code has been refactored the location for myclass.java has been changed to "d.g.f.myclass.java" so while data fetched from DB tried to find "A.b.c.myclass.java" which is not there now as its new location is "d.g.f.myclass.java" and hence giving me SerializationException. So what is the best way to handle this exception in this case.
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create a dummy package with old definition, read the blob, typecast it, get the class file and finc out the version number.
Use that same for your new package. Try if this works.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic