java - Why does Hibernate return random result? -


i want read data database using hibernate. want start first row, read 200 rows , process them, read next 200 rows. hibernate returns random row every time.

this method reads database.

public list getpages(int start, int end) {     criteria querycriteria = session.createcriteria(page.class);     querycriteria.setfirstresult(start).setmaxresults(end);     return querycriteria.list(); }  public void myfunction(){     while (readflag) {          //get page database;         list<page> pageslist = database.getpages(startfromdatabaseindex,                     read_from_database_size);          if ((pageslist == null) || (pageslist.size() == 0)) {             break;         }         if (pageslist.size() < read_from_database_size) {                 readflag = false;         } else {             startfromdatabaseindex = startfromdatabaseindex + 200;         }          (int = 0; < pageslist.size(); i++) {              process();         }     } } 

to extract data database using pagination need define sort criteria based on wich can define mean first 200 rows, otherwise database (not hibernate) return 200 rows in order not defined , can change after modification of data on database.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -