-->
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: What you prefer setString vs setParameter
PostPosted: Mon Jan 05, 2015 11:49 am 
Newbie

Joined: Wed Dec 24, 2014 12:20 pm
Posts: 2
Hi all.
Let speak about Query and methods setString vs setParameter.

So.
1. setString
Code:
public Query setString(int position, String val) {
      setParameter(position, val, StandardBasicTypes.STRING);
      return this;
}


2. setParameter
Code:
public Query setParameter(String name, Object val) throws HibernateException {
      if (val == null) {
         Type type = parameterMetadata.getNamedParameterExpectedType( name );
         if ( type == null ) {
            type = StandardBasicTypes.SERIALIZABLE;
         }
         setParameter( name, val, type );
      }
      else {
         setParameter( name, val, determineType( name, val ) );
      }
      return this;
   }


Let speak if val !=null in this case different only on this :
Code:
[b]determineType( name, val )[/b]


SO. Question is: "What you prefer setString or setParameter for string value?"
In implementation we have difference. Do we have big difference on speed when we choosed one of them?
Cause setString() it is like what we have on JDBC. So what you think about this and if you prefer on of them let give answer for question "Why?"


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.