Hello,
I have created several UserType classes for my domain model custom value types. I have defined them in a package-info.java file using @TypeDef annotations (wrapped inside @TypeDefs). Then in my domain model classes, I annotate each such property with @Type. It is also necessary to include @Column so that the schema generator shows the correct type length (e.g. 'CHAR(10)') in the DDL file.
My questions are as follows...
1. Is it possible to bind (register) a UserType to the class, so hibernate automatically selects the correct type without the explicit @Type annotation? After all, this is what hibernate does for out of the box types, and is consistent with the annotate by exception policy.
2. Is it possible for the UserType to configure more than just the basic SQL column type (i.e. the Types.XXX value)? I would like to avoid the need to add the @Column everywhere. The only way I can see to do this is to subclass (or compose) a Dialect which registers a made up Types value which would then be returned by my UserType. This seems awkward though.
I would like to hear whether either of these items are possible, and if so the best way (or extension point) to implement them. If there is some philosophical reason why this is not done, I would be interested to hear that too.
Many thanks, Ross.
|