I have simple object with two field which extending the hazelcast DataSerializable interface. putting in that map working fine but while retrieving with same name its showing an exception says : 'Problem while reading DataSerializable, namespace: 0, ID: 0'.
I am using hazelcast client '3.12.4' and hazelcast cluster with latest docker base image.
Please let me know guys if anyone of you faced the similar issue? I have not used any db as of now for simplicity purpose. my hazelcast client only saves a simple object in IMap and then retrieving from IMap.
Please find my code snippet below:
Domain Object:
public class Employee implements DataSerializable {
private String name;
private Integer serialNumber;
public Employee() {
}
public Employee(String name, Integer serialNumber) {
this.name = name;
this.serialNumber = serialNumber;
}
** Getter and Setter **
@Override
public void readData(ObjectDataInput in) throws IOException {
this.name = in.readUTF();
this.serialNumber = (Integer) in.readInt();
}
@Override
public void writeData(ObjectDataOutput out) throws IOException {
out.writeUTF(name);
out.writeInt(serialNumber);
}
Hazelcast save and get:
IMap<String, Employee> map = hazelcastInstance.getMap("employee");
map.put(employee.getName(), employee);
EntryObject e = new PredicateBuilder().getEntryObject();
Predicate predicate = e.get("serialNumber").lessThan(200);
Collection<Employee> result = map.values(predicate);
}
Thanks in advance for your help.
readDatamethod ofDataSerializableto populate the fields. If you can post the class definition or even an mvce that would be helpful - Neil StevensonIMap.get(key)work ? You're doing a search so need the domain model on the serverside, see github.com/hazelcast/… - Neil StevensonDataSerializablethe domain model needs to be available serverside in order for the search to examine each record to determine if it is a match or not. Can you try adding the domain model to the classpath of the Docker container and report back ? - Neil Stevenson