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.

Combined Settings<strong>Query</strong> getAccountPage1 =session.create<strong>Query</strong>("from Account").setMaxResult(50).setFetchSize(50).setTimeout(60).setComment("Retrieving all account objects");List accounts = getAccounts.list();...<strong>Query</strong> getAccountNextPage =session.create<strong>Query</strong>("from Account").setFirstResult(:startingIndex).setMaxResult(25).setFetchSize(25).setTimeout(30).setComment("Retrieving page " + pageNum);Externalizing Queries• Define queries in object mapping files• Can be ‘global’ or included insideclass definition– If inside class definition, need to prefix with fullyqualified class name when calling• Isolates the SQL statements– Useful if you want to modify all queries• Optimize queries• Switch vendors• May not require recompiling code

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

Saved successfully!

Ooh no, something went wrong!