Hi Milosz,
Miłosz Tylenda-3 wrote:
>
> You might want to experiment with @Strategy or @Externalizer. See the
> links below.
>
Thanks. I implemented a custom ValueHandler:
public class CharValueHandler extends AbstractValueHandler {
...
@Override
public Object toDataStoreValue(ValueMapping vm, Object val, JDBCStore
store) {
if (val instanceof String) {
return pad((String) val, getLength(vm));
} else {
return val;
}
}
@Override
public Object toObjectValue(ValueMapping vm, Object val) {
if (val instanceof String) {
return trim((String) val);
} else {
return val;
}
}
}
where trim(..) and pad(...) are some string helper methods. This works fine.
But I have to annotate every single attribute like this:
@Column(unique = true, length = 50)
@Strategy("com.xxxx.beispielanwendung.firmenverwaltung.entity.CharValueHandler")
private String name;
Is there a more generic way? I'd like to register this strategy for all
columns of type CHAR or for all String attributes. Any hints?
TIA,
Tobias
--
View this message in context:
http://openjpa.208410.n2.nabble.com/Mapping-CHAR-column-to-String-tp5727930p5729450.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.