-->
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: criteria and filters using spring
PostPosted: Wed Jan 12, 2005 8:39 am 
Newbie

Joined: Thu Jan 06, 2005 7:27 am
Posts: 2
Location: India
Hi everybody,

I am using hibernate with spring transction magement. I extend the HibernateDaoSupport class and use the getHibernateTemplate() method to find, save and update objects in to the database. But it does not provide a direct way for me to create criteria instead of writing queries. I am requiered to explicitly pass a session objects to create a criteria object which is subsequently causing me many problems. It also provides no feature for me to create filters. I searched the web and found no related examples. PLEASE HELP!

Thank you in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 8:59 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Complain to the Spring guys if you can't access Hibernate anymore after you use their wrapper. Or don't use it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 9:23 am 
Newbie

Joined: Wed Jan 12, 2005 8:58 am
Posts: 3
If you want do do something that HibernateDaoSupport does not provide, you should try something like:
Code:
getHibernateTemplate().execute(new HibernateCallback(){
   public Object doInHibernate(net.sf.hibernate.Session session) throws HibernateException, SQLException {
           //do your stuff with the hibernate session here
           return .... ;
        }
});


In this way you get the access to the hibernate session. You also get the session/transaction management + exception handling of the Spring HibernateTemplate.


Top
 Profile  
 
 Post subject: Re: criteria and filters using spring
PostPosted: Wed Jan 12, 2005 11:57 am 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
We use objects that extend the Spring HibernateDAOSupport class. To create a criteria instance do this:

Criteria criteria = getSession().createCriteria(StandingDataRow.class);

_________________
On the information super B road


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.