Interface AnnotationBasedUserType<A extends Annotation, J>
- Type Parameters:
A- The user type annotation type supported by an implementationJ- The java type
- All Superinterfaces:
UserType<J>
A
UserType which receives parameters from a custom annotation.
Implementing this interface is the same as providing a constructor with the same
signature as the initialize(A, UserTypeCreationContext) method. But implementing this interface is
slightly more typesafe.
For example, implementing AnnotationBasedUserType<AnnotationType> is the
same as providing a constructor with this signature:
public CustomTypeClass(AnnotationType config,
UserTypeCreationContext creationContext)
where CustomTypeClass is the class that implements UserType, and
AnnotationType is the custom annotation type used to configure the custom
type. That is, it is an annotation type annotated
@Type.
@Type(CustomTypeClass.class)
public @interface AnnotationType { ... }
- Since:
- 7.3
-
Method Summary
Modifier and TypeMethodDescriptionvoidinitialize(A annotation, UserTypeCreationContext context) Initializes this generation strategy for the given annotation instance.Methods inherited from interface UserType
assemble, deepCopy, disassemble, equals, getDefaultSqlLength, getDefaultSqlLength, getDefaultSqlPrecision, getDefaultSqlPrecision, getDefaultSqlScale, getDefaultSqlScale, getSqlType, getValueConverter, hashCode, isComparable, isMutable, nullSafeGet, nullSafeGet, nullSafeSet, nullSafeSet, replace, returnedClass
-
Method Details
-
initialize
Initializes this generation strategy for the given annotation instance.- Parameters:
annotation- an instance of the user type annotation type. Typically, implementations will retrieve the annotation's attribute values and store them in fields.context- aUserTypeCreationContext.- Throws:
HibernateException- in case an error occurred during initialization, e.g. if an implementation can't create a value for the given property type.
-