aspose file tools*
The moose likes Object Relational Mapping and the fly likes stored procedures vs JDBC batch updates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "stored procedures vs JDBC batch updates" Watch "stored procedures vs JDBC batch updates" New topic
Author

stored procedures vs JDBC batch updates

sivaraman syntel
Greenhorn

Joined: Dec 27, 2005
Posts: 2
1. In a given transaction, if I need to insert/update few records (say around 5 records) in different tables (say around 5 tables), can someone tell me which is the best approach to follow: JDBC batch updates or stored procedures?

2. We are going to use Hibernate3.0 in our project. In that case which is the prefered solution: Using JDBC batch updates through Hibernate or using stored procedures through Hibernate?

Thanks
Sivaraman
Greg Fidster
Greenhorn

Joined: Dec 08, 2004
Posts: 10
depends on your performance needs

for 5 records for 5 tables, executing sql statements should be no problem.

if you are writing some financial application that needs to do this thousands of times per minutes then stored procs are always the fastest means of executing crud to the database.

if milliseconds don't mean much to you, then hibernate will make your code much more manageable going forward with changes and extensions to your codebase since then you have the means to create model objects and map your database tables in hbm.xml files and simple write code thats as simple as.. er um.. hey lets even use Spring as a framework! ::



hibernate is pretty well designed so that it doesn't add much overhead versus using raw JDBC. the only reason to not use hibernate would be if you truely need the speed of stored procs, or your database is so old and legacy with no good indexing or ids, hibernate becomes a pain to do true mappings. hibernate simply loves good data models.
sivaraman syntel
Greenhorn

Joined: Dec 27, 2005
Posts: 2
Thanks for the details. We have planned to use Spring also.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: stored procedures vs JDBC batch updates