Giter Site home page Giter Site logo

Comments (4)

jankotek avatar jankotek commented on July 17, 2024 1

I think you are mixing old data format with new one. Write your own serializer and handle such cases there.

from mapdb.

hlms avatar hlms commented on July 17, 2024

This got solved in the following way:

Earlier, map looked like the following:

HTreeMap map = db.hashMap("Detail")
            .createOrOpen();

Fixed version:

HTreeMap<String, Detail> map = db.hashMap("Detail", Serializer.STRING, Serializer.JAVA)
            .createOrOpen();

Add serialVersionUID to the class:

@Data
@NoArgsConstructor
public class Detail implements Serializable {
  private static final long serialVersionUID = -4627389989283518760L;
  private String source;
  private String target;
}

Store some objects with string key and this class objects as values.

Now, update the class definition leaving the serialVersionUID unchanged:

@Data
@NoArgsConstructor
public class Detail implements Serializable {
  private static final long serialVersionUID = -4627389989283518760L;
  private String source;
  private String target;
  private int state;  // new field 
}

Persist some more objects with this class object values.

Now, you will be able to read old and new objects with this class.

@jankotek ,

Note that - in the reported scenario in my previous comment - the exception is thrown when user attempts to persist the object with new definition.
User is NOT even attempting to read the old definition objects.
Why is the exception required in this case?

from mapdb.

hlms avatar hlms commented on July 17, 2024

This looks like an issue to me. Why does mapdb need to throw an exception (about already persisted data in past) while writing new data?

from mapdb.

hlms avatar hlms commented on July 17, 2024

@jankotek ,
Could you re-open this issue?

from mapdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.