hitaco
发贴: 432
积分: 31
|
于 2004-06-16 23:17
page 4, User-->VO I guess in some situations User may represent Business object/Domain object, for example, in hibernate architecheture, object can be detached, we do not need VO just holding data for business object.
page 6: ResultSet/Paging/ResultSet::absolute() Some JDBC driver will not skip the data. Suppose we have 10000 records in the query result and we are interested only in the 9999th row. rs.abolute(9999) is not good concerning the performance, it will not be more efficient than looping the resultset from the very begining, which will cost much more time than rownum approach. (BTW: I have tested this in oracle driver)
page 9: query by inner class, anonymous inner class are good when used as strategy objects, but most developers will be confused with the syntax, my opinion about inner class is: do not put too much code in the inner class, in some situations, we can create a helper method which will be invoked from the inner class.
String[] getAllUsername() { final ArrayList list = new ArrayList(); return (String[]) jdbcTemplate.query("select name from user", new RowCallbackHandler() { public void processRow(ResultSet rs) throws SQLException { list.add(rs.getString("name")); } })
return ...... }
about RuntimeException/Checked Exception: I have seem many applications just try/Catch SQLException in DAO and wrap as app-specific exception, rethrown it, and let session bean layer to catch it and call SessionContext::setRollbackOnly(), it's not good, I prefer touse RuntimeException and let EJB Container automatically rollback the transaction, BTW, I do not know how hibernate deal with transaction when RuntimeException occurs.
|