java - InvalidClassException while deserializing blob field from database -


When I was trying to get the data drops from the database (mysql), I found the exception below.

  java.io.InvalidClassException: com.nmsworks.cygnet.tmf.mtnm.elements.SNCUserData; Local Class Incompatible: Stream Classes Serialvarsion UID = -7634696886161105104, Local Class SerialVersion UID = -7522169448179471613  

I believe some code changes after data Stored in class database I did not declare a default serial version uid in class. I can see what the problem is. If I had declared a UID, then I would not have received this exception. My question is instead of storing the object in the database as Bbq, is there any other way of saving the object so that I do not need to serialize and deorize the object whenever I store it and store it again from the database? I do not want to declare a serial variant UID in class because it is a heavy structure, in return for which there are many serial objects, for which I have to declare the UID inside it.

I believe that after the data is stored in the database, some changes are made to SNCUserData class I did not declare a default serial version UID in class. I can see what the problem is.

This will be enough to cause problems.

If I have declared a UID, then I will not get the exception.

That's right. But you can get different exceptions; Like if you have added, deleted, rearranged or changed any kind.

My question is instead of storing the object in the form of a drop in the database, there is another way to save that object so that whenever I store it and retrieve it from the database, Then I do not need to serialize and deorize the object?

The option to create a new table or tables with columns to represent the field of the object. Then type some Java code to map between objects and table rows.

I do not want to declare serial version UID in class, because it is a heavy structure, which in turn is a lot of serial objects, for which I have to declare the UID inside it.

Good, yes. But this is less than your concerns. If you start declaring a serial UID, then if you change the structure of the classes, then you may have to type custom readObject and writeObject to deal with it.

What is the value for it, putting things in a database is usually a bad idea. The "modern" approach to continuing complex objects is to use an object-relational mapping such as JPA (like Hibernate) or JDO, but still, you may be involved in problems if you make revolutionary changes in the continuously created sections .


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -