JPA generic field
Posted
by
m.ugues
on Stack Overflow
See other posts from Stack Overflow
or by m.ugues
Published on 2011-01-11T15:50:12Z
Indexed on
2011/01/11
15:53 UTC
Read the original article
Hit count: 161
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
© Stack Overflow or respective owner