Saturday, July 12, 2008

To View the SQL Being executed in Ibatis.

To View the SQL Being executed in Ibatis.
Use com.ibatis.sqlmap.engine.mapping.SimpleDynamicSql.java's getSql() method in Ibatis.jar. This method gives you the sql being executed by the ibatis data mapper after all the dynamic elements have been replaced.

Sphere: Related Content

4 comments:

Anonymous said...

How does one obtain an instance of SimpleDynamicSql in order to call its getSql method?

Anonymous said...

iBATIS will log your queries using commons-logging automatically. If you are using log4j, simply set the logger to debug level:

log4j.logger.java.sql=DEBUG

See this link for more details.

Derek said...

Yes, I would like to see a short snippet as how this might work. As Demi1 asked how does one obtain an instance of SimpleDynamicSql? Could you please elaborate on your approach a bit? I have checked nabble as well as iBATIS docs and not found anything on this.

As to the other peoples comments, I am not referring to simple logging which already I have working.

Thanks for any additional details you can provide on this interesting approach.

Unknown said...

Demi1 and Derek,

You can put a breakpoint in your favorite IDE of your choice. I usually did this for the SimpleDynamicSql class of Ibatis.

Anonymous,
Thanks for sharing the link.

Ahsan