Is there any way where I can get the executed query of iBatis? I want to reuse the query for an UNION query.
For example:
<sqlMap namespace="userSQLMap">
<select id="getUser" resultClass="UserPackage.User">
SELECT username,
password
FROM table
WHERE id=#value#
</select>
</sqlMap>
And when I execute the query through
int id = 1
List<User> userList = queryDAO.executeForObjectList("userSQLMap.getUser",id)
I want to get SELECT username, password FROM table WHERE id=1
Is there any way I could get the query?
Thanks.
How iBATIS works. iBATIS allows loose coupling of the database and application by mapping the input to and output from the database to the domain objects, thus introducing an abstraction layer. The mapping is done using XML files that contain SQL queries.
MyBatis does four main things: It executes SQL safely and abstracts away all the intricacies of JDBC. It maps parameter objects to JDBC prepared statement parameters. It maps rows in JDBC result sets to objects.
iBATIS was a data mapper framework that made it easier to use a relational database with object-oriented applications.
Add this to your log4j.xml file and you can see the output on console.
<logger name="java.sql" additivity="false">
<level value="debug" />
<appender-ref ref="console" />
</logger>
You will see the parameters being passed, the query being executed and the output of query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With