ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Ellis <ellis....@gmail.com>
Subject Re: Custom ResultSet handler
Date Tue, 02 Feb 2010 11:43:14 GMT
On 2 February 2010 09:20, Stephen Friedrich
<stephen.friedrich@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());
            rs = stmt.executeQuery();

I don't really like it.  Manually handling the result set is probably
a premature optimisation for my use case.  But you live and learn.


To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org

View raw message