views:

274

answers:

1

How much of a performance difference is there between these two models? What kind of reasons are there for using one over the other?

In my application I am using a lot of the same statements over and returning both Objects and primitives. There are a few oracle stored procedure calls and performance on these is a top priority.

+1  A: 

Perhaps, the intention is best captured in the spring doc - RdbmsOperations are designed capture sql operation as reusable objects. For example, you can have a UpdateAcccount as a operation, and you only pass in the required parameters each time you call it. As it is of its own custom class, the type check and validation logic can be custom made. JDBCTemplate is, on the other hand, modelled after traditional JDBC, where you pass sql, parameters, the row mapper each time you make a call. You probably need to build validation logic and parameters conversion on top of it on your own.

The org.springframework.jdbc.core package contains the JdbcTemplate class and its various callback interfaces, plus a variety of related classes.

Next, the org.springframework.jdbc.object package contains classes that represent RDBMS queries, updates, and stored procedures as thread safe, reusable objects. This approach is modeled by JDO, although of course objects returned by queries are “disconnected” from the database. This higher level of JDBC abstraction depends on the lower-level abstraction in the org.springframework.jdbc.core package.

I do not know performance difference, but the RdmsOperation codes are pretty straightforward, so I don't it will incur any significant overhead. However, like the doc said, it is more a programming choice. Some people find former one is more OO, while some people find the traditional one is more straightforward.

Oscar Chan