Results 1 to 2 of 2

Thread: how can i use the "in" condition with HibernateTem

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    Paris-France
    Posts
    31

    Default how can i use the "in" condition with HibernateTem

    I want to get the result of an SQL query like:
    select * from myTable where property in (my list).
    my problem is: how can i use the "in" condition with Hibernate.
    can i do it whith hibernatetemplate ?
    i try this code
    Code:
    public class HibernateTransactionDao extends HibernateDaoSupport {
    public List findTransactionsToUpdate(String msisdns) 
    	throws DataAccessResourceFailureException, HibernateException, IllegalStateException {
    		
    		
    		Session session= getSession(true);
    		session.setFlushMode(FlushMode.AUTO);
    		final List transactions=session.find("select tr from com.posanet.model.Transaction as tr where tr.msisdn in ('"+msisdns+"')");
    		
    		
            if (transactions.size() == 0) {
                return null;
            }
            return transactions;
    	}
    ...
    }
    this methode return my list, the list is not empty, so when i parse it, the objects are empty. all of property are null.

    sorry, i have a low level in "english".
    think's

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Yes, you can use the HibernateTemplate or, if you want to do more work on the session and the HibernateTemplate API is not sufficient, use HibernateCallback.
    As for creating the HB query, read HB reference documentation as it includes excelent examples.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Similar Threads

  1. Replies: 7
    Last Post: May 16th, 2005, 10:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •