On 2 February 2010 11:43, Martin Ellis <ellis....@gmail.com> wrote: > On 2 February 2010 09:20, Stephen Friedrich > <stephen.friedr...@fortis-it.eu> wrote: >> Another option for me would be to somehow get the final SQL statement and >> parameters, then execute that statement myself. Is that possible somehow? > > I have something like this: > > String sqlId = ... // The 'id' of the SQL statement in the XML config > Object param = ... // The parameter object for the query > ResultSet rs = null; > PreparedStatement ps = null; > try { > Configuration conf = sf.getConfiguration(); > MappedStatement ms = conf.getMappedStatement(sqlId); > BoundSql boundSql = ms.getBoundSql(param); > ParameterHandler pHandler = new > DefaultParameterHandler(ms, param, boundSql); > > stmt = conn.prepareStatement(boundSql.getSql()); > pHandler.setParameters(stmt); > rs = stmt.executeQuery();
In the above, conn is initialised as follows: Environment env = sf.getConfiguration().getEnvironment(); conn = sf.getConfiguration().getEnvironment().getDataSource().getConnection(); Transaction txn = env.getTransactionFactory().newTransaction(conn, false); Probably want to commit/rollback your txn afterwards. Martin --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org