@Ali_Titan For deserialization, you should have the below class in camunda classpath.
com.camunda.demo.test.PersonnelModel
Serialization:
ObjectValue typedObjectValue = Variables
.objectValue(order)
.serializationDataFormat(Variables.SerializationDataFormats.JAVA)
.create();
Access serialized properties:
// returns true
boolean isDeserialized = retrievedTypedObjectValue.isDeserialized();
// returns the format used by the engine to serialize the value into the database
String serializationDataFormat = retrievedTypedObjectValue.getSerializationDateFormat();
// returns the serialized representation of the variable; the actual value depends on the serialization format used
String serializedValue = retrievedTypedObjectValue.getValueSerialized();
// returns the class com.example.Order
Class<com.example.Order> valueClass = retrievedTypedObjectValue.getObjectType();
// returns the String "com.example.Order"
String valueClassName = retrievedTypedObjectValue.getObjectTypeName();
Deserialization:
String serializedOrder = "...";
ObjectValue serializedValue =
Variables
.serializedObjectValue(serializedOrder)
.serializationDataFormat(Variables.SerializationDataFormats.JAVA)
.objectTypeName("com.example.Order")
.create();
runtimeService.setVariableLocal(execution.getId(), "order", serializedValue);
ObjectValue retrievedTypedObjectValue = runtimeService.getVariableTyped(execution.getId(), "order");
com.example.Order retrievedOrder = (com.example.Order) retrievedTypedObjectValue.getValue();
Read about Serializing Process Variables
Custom Java objects can be serialized with the value type object:
https://docs.camunda.org/manual/latest/user-guide/process-engine/variables/#object-values
Object Value Serialization:
https://docs.camunda.org/manual/latest/user-guide/process-engine/variables/#object-value-serialization