JPA generic field
- by m.ugues
Hallo all
Is it possible to persist a generic field?
I have this property on an Entity class
...
private T payload;
...
T extends EventMessagePayload
and
public interface StringPayload extends EventMessagePayload{
String getPayload();
}
In my application i persist the field only when is of String type and during the save operation all works great.
When I read the object instead JPA try to create a String object but instead is a StringPaylod. Is there a way to intercept the creation and handle the object marshalling?
Kind regards
Massimo