Get SQL statement from generated class

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Get SQL statement from generated class

Hsu Henry
Hi there,

I have the MyBatis auto-generated Mapper and Example classes and is trying to get the SQL statement as a String text in my code.
Is there a way I can do this? I know it gets logged in the log file, however I would like to access the statement before it gets logged.

SqlSession session = mySqlSessionFactory.openSession();
MyMapper mapper = session.getMapper(MyMapper.class);
MyExample example = new MyExample();

// TODO: get the SQL string here?

List<My> myList = mapper.selectByExample(example);

I would like to obtain a String that looks like: select * from `my` where name = 'Name';
before the mapper executes the selectByExample(example).

Kind Regards,

You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit