13.07.2015 Views

Hibernate Query Language Hibernate Query Language and Native

Hibernate Query Language Hibernate Query Language and Native

Hibernate Query Language Hibernate Query Language and Native

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Binding by Object// return all Accounts based on// balance <strong>and</strong> creation dateString query = "from EBill e where"+ " e.balance > :balance"+ " <strong>and</strong> e.ebillerId > :ebillerId";EBill queryParams = new EBill();queryParams.setBalance(1000);queryParams.setEbillerId(1);Assume an object with attribute namesthat matched the placeholder names...// this will use java bean properties/reflection// to bind the variables<strong>Query</strong> getEBills = session.create<strong>Query</strong>(query).setProperties(queryParams);List accounts = getEBills.list();…pass that object in toset the parameter valuesPagination• Break up large result sets into smallergroups (pages)– setFirstResults(int startRow);• Set the starting record position• Zero-based indexing– setMaxResults(int t numberToGet);• Set the number of records to retrieve• Keep track of current index in order tocontinue paging data through the data

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!