-->
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.  [ 10 posts ] 
Author Message
 Post subject: issue with createFilter
PostPosted: Wed Jan 20, 2010 11:56 am 
Newbie

Joined: Wed Jan 20, 2010 11:40 am
Posts: 5
Hi,

I having an issue with using createFilter.

When I use the following I'm get 25 records (there are 25 records in database).

(List)this.getSession().createFilter( cust.getInvoices(), "order by this.invoicedate DESC" ).list()).size()

But When I use the following createFilter, I'm getting only 10 records. Executing the same in other environments like DEV, I'm getting 15 records

(List) this.getSession().createFilter(
cust.getInvoices(),
"order by this.invoicedate DESC").setFirstResult(0).setMaxResults(15).list()


Can somebody please help me understand why I'm getting less number of records when I'm using setMaxResults()..?

Thanks,
Anu


Top
 Profile  
 
 Post subject: Re: issue with createFilter
PostPosted: Wed Jan 20, 2010 1:24 pm 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
Hi,
are you working with the same customer instance in both the cases and both of them have the same invoices in the databases you are working with?
-Srilatha.


Top
 Profile  
 
 Post subject: Re: issue with createFilter
PostPosted: Wed Jan 20, 2010 1:32 pm 
Newbie

Joined: Wed Jan 20, 2010 11:40 am
Posts: 5
Yes,

I'm working with same customer and same number of invoices.


Top
 Profile  
 
 Post subject: Re: issue with createFilter
PostPosted: Wed Jan 20, 2010 2:00 pm 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
using the original query in your Dev environment returns the expected results?

(List)this.getSession().createFilter( cust.getInvoices(), "order by this.invoicedate DESC" ).list()).size()


Top
 Profile  
 
 Post subject: Re: issue with createFilter
PostPosted: Wed Jan 20, 2010 2:09 pm 
Newbie

Joined: Wed Jan 20, 2010 11:40 am
Posts: 5
using this query
(List)this.getSession().createFilter( cust.getInvoices(), "order by this.invoicedate DESC" ).list()).size()
is giving correct value.

Actually the code is in Production and sometimes the following query is displaying 15 records and sometimes 10. It is consistently displaying 15 records in all other environments and hence not able to reproduce the issue in other environments..


(List) this.getSession().createFilter(
cust.getInvoices(),
"order by this.invoicedate DESC").setFirstResult(0).setMaxResults(15).list();


I changed the above query to the following and I'm getting the 15 records consistently. I', not able to understand why the above query is not working all the time.

(List) this.getSession().createFilter(
cust.getInvoices(),
"order by this.invoicedate DESC").list().subList(0, 15);


Top
 Profile  
 
 Post subject: Re: issue with createFilter
PostPosted: Wed Jan 20, 2010 2:21 pm 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
what kind of collection does the cust.getInvoices() returns? List or Set of Invoice instances? Also does the Invoice instance has implementation of hashCode and equals method?


Top
 Profile  
 
 Post subject: Re: issue with createFilter
PostPosted: Wed Jan 20, 2010 2:29 pm 
Newbie

Joined: Wed Jan 20, 2010 11:40 am
Posts: 5
Cust.getInvoices() returns Set. Invoice has no implementation of hashCode and equals methods


Top
 Profile  
 
 Post subject: Re: issue with createFilter
PostPosted: Thu Jan 21, 2010 10:45 am 
Regular
Regular

Joined: Wed Jun 20, 2007 1:53 am
Posts: 75
Enable 'show_sql' property in configuration file and get the corresponding generated SQL query for your HQL.

execute that SQL in database and see the result


Top
 Profile  
 
 Post subject: Re: issue with createFilter
PostPosted: Thu Jan 21, 2010 11:51 am 
Newbie

Joined: Wed Jan 20, 2010 11:40 am
Posts: 5
It is generating the following query . When I executed it in DB giving teh rownum as 15, I'm getting 15 Invoices. How do we know what value is being used for rownum ?

select * from ( select invoice0_.INVOICEID as INVOICEID82_, invoice0_.DUEDATE as DUEDATE82_, invoice0_.TOTALAMOUNTDUE as TOTALAMO3_82_, invoice0_.INVOICEDATE as INVOICED4_82_, invoice0_.CREATEDDATE as CREATEDD5_82_, invoice0_.CREATEDBY as CREATEDBY82_, invoice0_.MODIFIEDDATE as MODIFIED7_82_, invoice0_.MODIFIEDBY as MODIFIEDBY82_, invoice0_.INVOICEGROUPID as INVOICEG9_82_, invoice0_.INVOICEFILENAME as INVOICE10_82_, invoice0_.ISFILEAVAILABLE as ISFILEA11_82_, invoice0_.TOTALNEWCHARGE as TOTALNE12_82_, invoice0_.FILEAVAILABLEDATE as FILEAVA13_82_, invoice0_.CUSTID as CUSTID82_ from INVOICE invoice0_ where invoice0_.CUSTID = ? order by invoice0_.INVOICEDATE DESC ) where rownum <= ?


Top
 Profile  
 
 Post subject: Re: issue with createFilter
PostPosted: Fri Jan 29, 2010 9:58 am 
Regular
Regular

Joined: Wed Jun 20, 2007 1:53 am
Posts: 75
Hi,

I suggest you to do the remote debugging to know what value is passed to rownum.

not sure which server and IDE you are using, but there are lot of articles in web to know how to do remote debugging for any server with and IDE.

you can find the number of objects inside the set/collection in your case if you do remote debugging


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.