s it possible to get the count of the records in the table ?
one of my files is having more than 100,000 records and i want to show the total count to the user. When I make the select I get heap error (out of memory space errror) for more than 100,000 records
here is the code, i had to put the setMaxResults to avoid the memory error, but what I also need is the total count of records in the file
public Newsletter[] getAllCustomers()
{
List customers = new ArrayList();
List allnewsletter = new ArrayList();
Transaction tx = null;
Session session = HibernateSessionFactory.getSession();
session.beginTransaction();
Criteria criteria = session.createCriteria(Newsletter.class);
int size = criteria.list().size();
// here i get heap error but i need to get the total count
criteria.setMaxResults(1000);
allnewsletter = criteria.list();
tx.commit();
for (Iterator iter = allnewsletter.iterator(); iter.hasNext() {
customers.add((Newsletter) iter.next());
}
return (Newsletter[]) customers.toArray(new Newsletter[0]);
}
Thanks
Rizwan
http://www.rizwan.in
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html