You could start digging by implementing an instance of AbstractValueHandler.
Implement at least theses three methods:
map(ValueMapping vm, String name, ColumnIO io, boolean adapt) {
Column col = new Column();
col.setName(name);
col.setJavaType(...);
col.setTypeName(...); //ddl column type name goes here (for
db-specific types)
return new Column[]{ col };
}
toDataStoreValue(ValueMapping vm, Object val, JDBCStore store) {
if (val == null)
return null;
//conversion goes here
...
}
toObjectValue(ValueMapping vm, Object val) {
if (val == null)
return null;
//conversion goes here
...
}
More details on custom mapping is here:
http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_mapping_custom.html
Miroslav Šulc wrote:
>
> Hi,
>
> I'd like to migrate my project to JPA using OpenJPA. I use two kinds of
> custom classes for fields:
> - classes that encapsulate java.lang.String in some specific way, like
> PhoneNumber.class etc.
> - classes that work over special PostgreSQL types inet and macaddr
> (Inet4Address.class, Inet4Network.class and MACAddress.class)
>
> I found out that OpenJPA is easily extensible so it should be possible
> to support my custom classes, but I am not that experienced so I'd
> appreciate if someone more experienced could tell me what exactly should
> I do to make my field classes persistable.
>
> Thank you for any hint.
>
> Miroslav
>
>
--
View this message in context:
http://n2.nabble.com/Using-custom-classes-for-field-tp2022021p2090539.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.