-->
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: setParamter vs setLong, etc.
PostPosted: Wed Feb 15, 2012 5:55 pm 
Newbie

Joined: Wed Feb 15, 2012 5:50 pm
Posts: 2
Is it always better to just use query.setParameter() instead of type-specific methods like query.setLong(), etc., since Hibernate would automatically do the correct type-matching based on the mapping file? Is there any cons to this?


Top
 Profile  
 
 Post subject: Re: setParamter vs setLong, etc.
PostPosted: Thu Feb 16, 2012 3:25 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
One advantage with using setLong() and other type-specific methods are that you get compile-time errors in case you change parameter type. With setParameter() you'll only get a run-time error which may be harder to track down.


Top
 Profile  
 
 Post subject: Re: setParamter vs setLong, etc.
PostPosted: Thu Feb 16, 2012 10:10 am 
Newbie

Joined: Wed Feb 15, 2012 5:50 pm
Posts: 2
Thank you!


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.