tenwit wrote:
No. This is a good situation to continue to use JDBC. That code probably shouldn't be migrated to hibernate.. except to use session.connection() to get the connection, instead of getting a whole new connection.
Thanks, that's a good point about connections. I'm not sure how to proceed, however.
The "complicated logic goes here" part of my JDBC-based code really is fairly complicated. I would love to replace it with a simpler POJO abstraction; I.e., I'd like to replace this:
Code:
String foo = rs.getString("foo");
Integer bar = rs.getInt("bar");
Boolean baz = rs.getBoolean("baz");
// Complicated logic goes here...
rs.updateString("foo", foo);
rs.updateInteger("bar", bar);
rs.updateRow();
With something like this:
Code:
LineItem pojo = loadLineItem(rs);
doComplicatedLogic(pojo);
updatePojo(rs, pojo);
The problem is that, when I change my data model, I need to change my code in at least three places: the SQL query that retrieves the rows, the code that maps recordset columns to local variables, and the code that updates recordset columns with newly calculated values.
Is there a way I can use Hibernate's mapping layer to somehow simplify this process ? I.e., can I somehow get Hibernate to supply me with the loadLineItem and updatePojo methods, as well as (hopefully) a portion of the SQL statement ?
(EDIT: typos)