ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Can ibatis work with java object with constructor have parameters?
Date Tue, 09 Jan 2007 13:00:27 GMT
Bah, gmail messed up my code...let's try again...

===

    Reader reader;
    SqlMapClientImpl smc;
    SelectStatement statement;
    String sql;

    // this is just plumbing:
    reader = Resources.getResourceAsReader("com/mwt/config/sqlmap.xml");
    smc = (SqlMapClientImpl) SqlMapClientBuilder.buildSqlMapClient(reader);

    // At this point, you can get a statement and get freaky with it
    // ...all unsupported of course, and if a later release breaks it, you
    // have been warned. :-)
    statement = (SelectStatement)
        smc.getDelegate().getMappedStatement("Customers.fetch");

    // replace the 2nd parameter below with YOUR parameter object, a
    // bean or map or whatever.
    sql = statement.getSql().getSql(null, null);

    // ALSO, who says this has to be SQL? it could be HQL, or an LDAP query, or
    // whatever other crazy stuff you want to try. This is the result
    // in any case:
    System.out.println(sql);

===

Larry

Mime
View raw message