A - the mapped typeB - the stored persisted typepublic interface Converter<A,B>
public class URIConverter implements Converter<URI, String> {
...
}
and implement the corresponding methods for converting the URI to and from a string. Then it can
be registered via mapping or in the entity class like so:
@Entity
public class AbstractUser {
@Convert(URIConverter.class)
URI homepage
}
}
When used with the Convert annotation the converter must have a no argument constructor
or compilation will fail.Convert| Modifier and Type | Method and Description |
|---|---|
A |
convertToMapped(Class<? extends A> type,
B value)
Convert the persisted type B to the mapped type A.
|
B |
convertToPersisted(A value)
Convert the mapped type A to the persisted type B.
|
Class<A> |
getMappedType() |
Integer |
getPersistedSize() |
Class<B> |
getPersistedType() |
@Nullable Integer getPersistedSize()
B convertToPersisted(A value)
value - to convert