Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Hibernate migration 3.5* to 3.6*, Type mapping
PostPosted: Mon Nov 28, 2011 6:22 am 
Newbie

Joined: Mon Nov 28, 2011 5:54 am
Posts: 1
Hi all,

In our existing database, which we can't change, there are some columns defined as char(240).
Hibernate pre 3.6.8 could not handle this well, so we had to upgrade to hibernate 3.6.8

3.6.* features an overhaul of the TypeFactory, so where you used to do:
Code:
NullableType type = (NullableType) TypeFactory.basic(identifierType.getName());

You now do something like:
Code:
BasicType type = new TypeResolver().basic(identifierType.getName());


Now because the @Type is pointed at my custom "UserType" class, the following function requires to be implemented:
Code:
public int[] sqlTypes()


Since TypeResolver().basic always returned a NullableType based class, using the pre 3.6.* hibernate we could use, :
Code:
@Override
public int[] sqlTypes() {
   // type is here of type NullableType
   return new int[]{type.sqlType()
};


Using the 3.6.* hibernate, we get a BasicType class, which can either be a PrimitiveType, NullableType or SingleColumnType.
Both NullableType(which is actually deprecated now) and SingleColumnType describe the sqlType() function to be implemented, but the PrimitiveType does not and neither does the BasicType class.

In the Type class the following function is available:
Code:
public int[] sqlTypes(Mapping mapping)


Now to my question
Is the BasicType and/or PrimitiveType class missing the defined sqlType() declaration?
And/or if I should be using the
Code:
public int[] sqlTypes(Mapping mapping)
function, how do I actually get that Mapping class?

Personally I'd say, sqlType() should be present in the interface classes BasicType & PrimitiveType, but I know too little of the entire Hibernate internals to be the judge of that.

Thanks in advance.

Regards,
Marco


Top
 Profile  
 
 Post subject: Re: Hibernate migration 3.5* to 3.6*, Type mapping
PostPosted: Thu Mar 22, 2012 12:59 am 
Newbie

Joined: Mon Oct 13, 2008 12:35 am
Posts: 1
I know am late (for >3 months). What you should look at is the SingleColumnType, not BasicType.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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.