-->
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.  [ 3 posts ] 
Author Message
 Post subject: Convert class type to hibernate type object
PostPosted: Tue Jul 27, 2004 11:04 am 
Senior
Senior

Joined: Sun Oct 26, 2003 5:05 am
Posts: 139
I was wondering what the factory class was to convert an object's class (like Date or String) to the equivalent Hibernate type (StringType or DateType for instance) was. The reason I'm asking is because session.iterate() takes in a Type[] array and that's not very convenient to handle generically. Here is the code I'm working with that returns the first value.

Code:
   protected Object findOneValue( final String queryString, final Object[] objects ) {
      HibernateCallback callback = new HibernateCallback() {
         public Object doInHibernate( Session session ) throws HibernateException, SQLException {
            Type[] types = new Type[ objects.length ];

            for( int i = 0; i < types.length; i++ ) {
               types[ i ] = ??
            }

            return session.iterate( queryString, objects, types ).next();
         }
      };

      return getHibernateTemplate().execute( callback );
   }



Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 11:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
TypeFactory - you can also use session.createQuery().iterate() which can do the type guessing for you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 11:30 am 
Senior
Senior

Joined: Sun Oct 26, 2003 5:05 am
Posts: 139
michael wrote:
TypeFactory - you can also use session.createQuery().iterate() which can do the type guessing for you.


Ahh, thanks so much.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.