-->
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.  [ 4 posts ] 
Author Message
 Post subject: Allow the addition of UserTypes in BASIC_TYPES
PostPosted: Wed Jun 23, 2004 5:01 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
Hi,

BASIC_TYPES are simpler to use than UserTypes because they can be guessed when you set a parameter of this type. They are also easier to use in the mapping files because they have a short name (with UserTypes you have to provide the full class name).

I want to have your opinion about a feature request relative to this.

It would be great to be able to add new BASIC_TYPES at startup. The simpler way is through the hibernate.cfg.xml file. It could be something like

Code:
<UserType name="oid" class="com.xyz.Oid" type="com.xyz.hibernate.OidType"/>


Then in the mapping files you can use your user type like this

Code:
    <id name="id" type="oid">
        <generator class="assigned"/>
    </id>

But the major advantage of this is that you can use setParameter(int, Object) with this type without the need to provide the type at runtime. The guesstype method can retrieve the type associated with the Oid class.

It seems to be a useful feature that can be quite simple to implement.

Any comments appreciated

Seb


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 23, 2004 10:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I think michael already implemented this in Hibernate3.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 23, 2004 11:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Yes, in Hibernate3 you can do

Code:
<typedef class="org.hibernate.test.NullMappingType" name="foreignNullMapper"/>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 23, 2004 11:54 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
It would be better to add the declaration of the class managed by the usertype. Thus you can use this association in the guessType method to retrieve the usertype

seb


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

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.