Using iBatis , How to get the SQL Statement that is executed based on SQL Id ?

1,616 views
Skip to first unread message

Naresh Jagatap

unread,
May 25, 2012, 2:33:39 AM5/25/12
to mybati...@googlegroups.com
Hi ,
 
I have the iBatis SQL Id  using which I need to get the corresponding  SQL Statement.
So I have written the below code . as of now this code seems to be working. but just want to know whether my approach is correct ?
 
 
SqlMapExecutorDelegate delegate = sqlMapClient.getDelegate();
MappedStatement mappedStatement = delegate.getMappedStatement(sqlId);
Sql sql = mappedStatement.getSql();
SessionScope sessionScope = new SessionScope();
StatementScope statementScope = new StatementScope(sessionScope);
mappedStatement.initRequest(statementScope);
String sqlExecuted = sql.getSql(statementScope,object);

c c

unread,
May 25, 2012, 9:16:25 AM5/25/12
to mybati...@googlegroups.com
if you config you log4j
you can easy see the sql in consloe;




2012/5/25 Naresh Jagatap <nare...@gmail.com>:

Dridi Boukelmoune

unread,
May 25, 2012, 11:41:51 AM5/25/12
to mybati...@googlegroups.com
Hi,

I believe it has been moved to the BoundSql class.
You can get the query from your mapped statement :

String sqlExecuted = mappedStatement.getBoundSql(statementScope,object).getSql();

Dridi
http://www.zenika.com/
--
 

http://www.whatsnextparis.com/images/sign/ligne.jpg

Dridi Boukelmoune

Développeur/Formateur

GSM : +33 (0)6 17 91 14 23
dridi.bo...@zenika.com

http://www.whatsnextparis.com/images/sign/logo.jpg
51, rue le Peletier - 75009 Paris
Tel : +33 (0)1 45 26 19 15

http://www.whatsnextparis.com/images/sign/ligne.jpg

 
image001.jpg
image002.jpg
Reply all
Reply to author
Forward
0 new messages