-->
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.  [ 2 posts ] 
Author Message
 Post subject: Works in SQL Server but not through Hibernate
PostPosted: Fri May 14, 2010 11:36 am 
Newbie

Joined: Fri May 14, 2010 11:31 am
Posts: 1
I'm having trouble getting a DetachedCriteria query workking. The same one works fine in SQL Server and brings back around 400 records, but none using the DetachedCriteria. Here is the code and all the names and model fields are correct, no misspelling or case issues. The startDate and endDate are java.util.Date objects

Code:
      DetachedCriteria d = DetachedCriteria.forClass(CaseInfoImpl.class);

      d.add(Restrictions.eq("causeOfAction",code));
      d.add(Restrictions.between("fileDate", startDate, endDate));
      if (!"All".equalsIgnoreCase(court))
      {
         d.add(Restrictions.eq("court", court));
      }
      d.addOrder(Order.asc("court"));
      logger.debug("getCasesByCauseOfAction criteria = " + d.toString());
      
      List<IEntity> searchList = getHibernateTemplate().findByCriteria(d);

      return searchList;


Is there any reason why this would return 0 records when the SQL query to the DB returns over 400?


Top
 Profile  
 
 Post subject: Re: Works in SQL Server but not through Hibernate
PostPosted: Wed May 19, 2010 3:59 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I suggest you to log the created sql-statements (with bound paramenters values) through p6spy
or through org.apache.log4j.jdbc.JDBCAppender and then compare it to the sql statement which you issue direct on sqlserver
(= the one which returns around 400 records).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.