Suppose you’ve been tasked with tracking down the memory usage of your application you’ve written with Hibernate. You’ve traced and tuned, and you think you should be able to squeeze more out of your database drivers. For this specific example we’ll say that we need to tune parameter bindings.
In order to more accurately control the amount of memory the driver allocates for each parameter in the PreparedStatement using Oracle's Thin driver, you must use the OraclePreparedStatement.defineColumnType() method (which is not part of the JDBC specification). WARNING! Note that if you re-bind your parameters on a subsequent execute using larger data sizes then the driver will be silently truncate to the size specified – which is bad. Also, due to the fact that Hibernate abstracts the actual JDBC calls themselves, you lose the power to customize these calls unless you modify the Hibernate code itself (casting the PreparedStatement to an OraclePreparedStatement in the process – Yuck!). This is generally unacceptable as it’s costly to modify the Hibernate code and you have to duplicate the code changes every time you upgrade the version of Hibernate you’re using. So, there goes option 1.
Tuning memory on a per statement basis with the Connect for JDBC Oracle driver is much less costly; with our drivers you just set a connect option (initalColumnBufferSize) to set the initial size you want us to try for each parameter. Score! Now we don’t have to change Hibernate code to tune the app! Also, we don’t have the limitation of truncating the data on subsequent executes and binds; we will auto-adjust for the parameter’s size so there's no need to spend time analyzing every parameter binding.
So, option 2 seems to be the way to go – it’s easy to use and doesn’t require modifying Hibernate’s internals to get it done!
As Senior Director of Research & Development, Jesse is responsible for the daily operations, product development initiatives and forward looking research for Progress DataDirect. Jesse has spent nearly 20 years creating enterprise data products and has served as an expert on several industry standards including JDBC, J2EE, DRDA and OData. Jesse holds a bachelor of science degree in Computer Engineering from North Carolina State university.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.Learn More
Subscribe to get all the news, info and tutorials you need to build better business apps and sites
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.