Here is the translation of your text into English:
---
One of our web applications is built on Tomcat and deployed in the form of a WAR package. The same WAR package behaves differently when running on different computers but within the same Tomcat instance. The difference lies in the fact that a Hibernate query in a certain DAO class returns fewer records. Below is the code:
```java
List l = this.getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Criteria c = dc.getExecutableCriteria(session)
.setMaxResults(pageSize)
.setFirstResult(firstResult);
return c.list();
}
});
```
Here, `dc` is of type `DetachedCriteria`. The number of entity records being queried is in the thousands. When `pageSize` is 15 and `firstResult` is 0, the returned list contains only 10 items. However, when `firstResult` is greater than or equal to 1, the list contains 15 items.
Now, there are two questions:
1. In the Hibernate query, the input parameter `maxresult` is set to 15, but the first page returns only 10 items. This issue occurs only in the production environment.
2. The problem resolves itself when a class is redeployed randomly during the Tomcat runtime. Why does this happen?
---
**Supplementary Question:**
jiangnan2112 wrote: "I once encountered a strange phenomenon where everything worked fine at the start on Tomcat, but after two to three days, the result set would suddenly lose many records. I never found out why. Later, I changed the way internal classes were executed and stopped using this method to obtain the Session. Since then, there have been no issues. Hopefully, this helps you."
Thank you! If I use Spring to integrate with Hibernate and need pagination, I only know how to do it this way. Are there other methods for pagination?
---
**Supplementary Question:**
This issue suddenly disappeared. It's too bizarre! I won't stop investigating.
---
**Supplementary Question:**
jiangnan2112 wrote: "The two parameters you passed must be of the final type. You don't think it's a bit strange or awkward that you get a `java.lang.reflect.InvocationTargetException`? Internal classes naturally use `final` parameters, and I guarantee that all parameters are correct before the `c.list()` statement, but the returned value is incorrect afterward."
---
**Solution Suggestions:**
- I once encountered such a strange phenomenon. At the beginning, everything ran fine on Tomcat, but after two to three days, the result set would lose many records. I couldn't find the reason. Later, I changed the way internal classes were executed and stopped using this method to obtain the Session. Since then, there have been no issues. Hopefully, this helps you.
- Does your method have parameters? Please share them with me!
- Please post the code where the ellipsis (...) appears. I suspect there might be an issue there. Additionally, Spring provides a wrapper for Hibernate, and it has a `getPageHibernateTemplate()` method that can also handle pagination.
- The two parameters you passed must be of the final type. Don't you think it's a bit strange or awkward?
- For reference: Strange phenomena in XFire webservice usage! [Link](http://www.myexception.cn/j2ee/10718.html)
Related articles:
- Using vsftp to upload `.sql` scripts to RedHat 5 systems but unable to execute
- Solving DWR GET request settings
- How to retrieve the current package value in Android
---
Let me know if you'd like further clarification or assistance!