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: find() method from hibernate 2 to hibernate 3
PostPosted: Mon May 09, 2005 1:26 pm 
Regular
Regular

Joined: Wed Sep 29, 2004 11:34 am
Posts: 62
Location: Houston, TX
Hibernate 2 had a find method which is now replaced in hibernate 3 with createQuery. It had three such overloaded methods:

(1) find(String arg0) - returns list
(2) find(String arg0, Object arg1, Type arg2) - returns list
(3) find(String arg0, Object[] arg1, Type[] arg2) - returns list

I know how to work with (1) find(arg0).list() , but I don't know how to work with (2) and (3). I know I can use the org.hibernate.classic.Session class, but I want to use the new API. Does anyone know its replacements.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 1:33 pm 
Newbie

Joined: Thu May 05, 2005 5:49 pm
Posts: 11
Location: San Diego, California
Code:
Query query = session.createQuery("from Table where Column = ?");
query.setString(0, "XXXX");


The Query class has methods similar to JDBC's PreparedStatement for setting the values into the query. In the above example I set a String but if you wanted to set a Long you would do something like:

Code:
query.setLong(0, new Long(1));


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 1:47 pm 
Regular
Regular

Joined: Wed Sep 29, 2004 11:34 am
Posts: 62
Location: Houston, TX
Like the old find() method, I am looking for more of a generic method. I am trying to implement some functionality of the DAO factory that was found in Hibernate Synchronizer (_RootDAO)


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 2:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The use one of the overloaded Query.setParameter() methods.


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.