0
votes

I am accessing a java object which is saved in hazelcast map from some other upstream system. I have the same java object structure but when I read the object and try to typecast it to my java object it throws ClassCast exception because my java object lies in some different package. How should we serialize the object while saving it in hazelcast so that it won't matter where my mapping java object reside(package)


Object in HZ

package com.varun.customer.bo;
  public class Customer{
     private long customerId;
 }

My Object

package com.varun.customer;
  public class Customer{
     private long customerId;
 }

Check the difference in package of both objects.

2

2 Answers

0
votes

You can have an application where you can have common classes and try using from that package at both the places. It will easy to maintain as you will need to change at 1 place.

0
votes

Hazelcast has several ways to serialize objects.

I suppose, you can try Custom serialization and implement your serialization/deserialization logic in write/read methods of StreamSerializer or ByteArraySerializer for each of your packages.