Interface ParameterizedType
- All Known Subinterfaces:
DynamicParameterizedType
- All Known Implementing Classes:
UserTypeLegacyBridge
public interface ParameterizedType
Support for parameterizable types. A
UserType or UserCollectionType
may be made parameterizable by implementing this interface. Arguments to parameters
may be specified via Type.parameters(). In XML,
parameters for a type may be set by using a nested type element for the property
element in the mapping file, or by defining a typedef.- See Also:
- API Note:
- This interface provides little type safety, and results in verbosity
at the use site. A much better approach is now provided by the possibility of
declaring a
UserTypevia an intermediate type annotation. Then the interfaceAnnotationBasedUserTypeprovides a modernized alternative approach to defining configurable custom types.For example, we could define a type annotation for the type
TimePeriod:@Type(PeriodType.class) // the type itself @Target({METHOD, FIELD}) @Retention(RUNTIME) // the type annotation: public @interface TimePeriod { // member specifying custom configuration // affecting the behavior of the UserType: boolean days() default false; }Then the
UserTypeimplementation receives an instance of the type annotation in its constructor, or viaAnnotationBasedUserType.initialize(A, UserTypeCreationContext):static class PeriodType implements AnnotationBasedUserType<TimePeriod,Period> { private final boolean days; // constructor configures the UserType from // information in the annotation instance: @Override void initialize(TimePeriod timePeriod, UserTypeCreationContext context) { days = timePeriod.days(); } // implementation of UserType operations: ... }This interface will eventually be deprecated.
-
Method Summary
Modifier and TypeMethodDescriptionvoidsetParameterValues(Properties parameters) Called by Hibernate to pass the parameters specified in the XML mapping file or byType.parameters().
-
Method Details
-
setParameterValues
Called by Hibernate to pass the parameters specified in the XML mapping file or byType.parameters().
-