3 Replies Latest reply on Jul 25, 2006 9:42 PM by Ben Wang

    POJO Mutations

    Larkin Lowrey Newbie

      Is there a way to deal with pojo structural chages? I believe Sleepycat calls such changes mutations.

      For example, say I convert a state variable from an int to an enum. What would PojoCache do in this case?

        • 1. Re: POJO Mutations
          Ben Wang Master

          Can you elaborate a bit more? Still not quite clear what you meant. Thanks!

          • 2. Re: POJO Mutations
            Larkin Lowrey Newbie

            Consider two scenarios.


            (i) Class A has member 'int state' where 'state' is set using a set of 'final static int' constants.

            (ii) Now, A gets altered so that 'state' is now an instance of an enum 'STATE {...}'.

            A node with class version (i) adds an instance of A into the PojoCache. What happens when a node with version (ii) tries to retrieve that same instance of A? Or, similarly, what happens when the CacheLoader tries to read a version (i) object when it has only the version (ii) class in its ClassLoader?


            (i) Class B extends A

            Say we need to change the structure so that we introduce a new class, C, so that...

            (ii) Class B extends C extends A

            If I have a serialized instance of (i) and try to deserialize with an instance of (ii) I'm going to have some heartburn. Granted, PojoCache is not (de)serializing, but I don't understand the logic well enough to understand how it will treat this case.

            Basically, as classes evolve over time, how does PojoCache handle the adding, deleting, and retyping of member fields?

            • 3. Re: POJO Mutations
              Ben Wang Master

              ic. Basically, PojoCache stores the class definition (Pojo Class) internally (in the cache) so they are static per se becuase we need it for replication purpose. So mutation won't really work, unless it is simple case of sub-classing.

              As for data evolution, I envision PojoCache is used for state not as entity. So the POJO should have a long life time but as not as long as entity, I'd say.