-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Minimising annotations on UserType properties
PostPosted: Thu Mar 19, 2009 7:04 pm 
Newbie

Joined: Fri Sep 26, 2003 1:50 pm
Posts: 9
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.