paging problem while doing with spring+Hibernate

i am trying to implement paging using Spring+Hibernate;what is PAGE_SIZE here?

when i run this class i am getting

Error(25,17): final method setSessionFactory(net.sf.hibernate.SessionFactory) in class eDaoSupport cannot be overridden by method setSessionFactory(net.sf.hibernate.SessionFactory) in class db.EmpObjectDaoImpl

import java.util.*;
import bus.Employee;
import org.springframework.orm.hibernate.HibernateTemplat e;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import eDaoSupport;
import org.springframework.orm.hibernate.SessionFactoryUt ils;
import net.sf.hibernate.Session;
import net.sf.hibernate.Query;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.ScrollableResults;

public class EmpObjectDaoImpl extends HibernateDaoSupport implements EmpObjectDao {

Employee emp = new Employee();
private SessionFactory sessionFactory;

public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;

* getAllMyObjectVOs
* @return List
* @todo Implement this org.annotationmvc.dao.MyObjectDao method
public List getAllMyObjectVOs() {

int PAGE_SIZE=10;
ArrayList pageOfCats =null;
ScrollableResults cats =null;

try {

Session sess= sessionFactory.openSession();
Query q = sess.createQuery("select, cat from DomesticCat cat " +
"order by");
cats = q.scroll();

if ( cats.first() ) {

// find the first name on each page of an alphabetical list of cats by name
ArrayList firstNamesOfPages = new ArrayList();
do {
String name = cats.getString(0);
while ( cats.scroll(PAGE_SIZE) );

// Now get the first page of cats
pageOfCats = new ArrayList();
int i=0;
while( ( PAGE_SIZE > i++ ) && ) pageOfCats.add( cats.get(1) );


}catch(HibernateException e)
System.out.println("catch block of getAllMyObjectVOs................");
return pageOfCats;

LVL 20
chaitu chaituAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

private SessionFactory sessionFactory;

public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;

get rid of that, it is already provided by base class
chaitu chaituAuthor Commented:
if i remove that line how will i get session object;i am getting this exception

Error(62,15): variable sessionFactory not found in class db.EmpObjectDaoImpl

i am new to Hibernate also Is it correct get session;

Session sess= sessionFactory.openSession();
Session sess = getSessionFactory().openSession();
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

chaitu chaituAuthor Commented:
what is PAGE_SIZE here???how will get PAGE_SIZE
you've set PAGE_SIZE to 10

int PAGE_SIZE=10;

chaitu chaituAuthor Commented:
in the consol after 3 records its showing

java.lang.ArrayIndexOutOfBoundsException: 1
chaitu chaituAuthor Commented:
i think PAGE_SIZE initialization is wrong
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
what makes you ythink that?
seems more likely your result row contains less than 2 objects

> while( ( PAGE_SIZE > i++ ) && ) pageOfCats.add( cats.get(1) );

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.