We have tables with legacy columns where SpecialStrings are stored. These SpecialStrings can't be NULL and they instead equal to some SPECIAL_UNICODE_NULL
.
So to send an entity back to a client via JAX-WS we have to either implement the whole Entity wrapper for sending it instead of Entity or to add convert logic explicitly to Entity get methods.
What we would like to do is to use our own @LegacyString
annotation.
@Column(name="A_LEGACY_COLUMN")
@LegacyString
public String oneOfThenLegacyColumn;
And then in the default Entity listener @PostLoad
we would transform all of the @LegacyString fields to regular string by using appropriate transformation.
But the problem with such solution is that after post load modifications entity is considered as changed and the Entity Manager will try to update it to the database. Of course I can use @PreUpdate
method to revert changes back. But I am not sure that this will prevent Entity from real update.
So the question is: How to change Entity Bean values View via own annotations?
P.S. I dig a little about ClassLoader and I am going to consider variant with adding changes in the load time. But I can't find an reasonable example with Application Server class loader case.