iBatis 获取执行的sql
有什么方法可以获取 iBatis 执行的查询吗?我想将查询重用为 UNION 查询。
例如:
<sqlMap namespace="userSQLMap">
<select id="getUser" resultClass="UserPackage.User">
SELECT username,
password
FROM table
WHERE id=#value#
</select>
</sqlMap>
当我通过执行查询时,
int id = 1
List<User> userList = queryDAO.executeForObjectList("userSQLMap.getUser",id)
我想获取SELECT username,password FROM table WHERE id=1
有什么方法可以获取查询吗?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
将其添加到您的 log4j.xml 文件中,您可以在控制台上看到输出。
您将看到正在传递的参数、正在执行的查询以及查询的输出。
Add this to your log4j.xml file and you can see the output on console.
You will see the parameters being passed, the query being executed and the output of query.
可以显示这些信息。iBatis 使用一些日志框架,包括
Log4J
。要使用
Log4J
在类路径中创建文件log4j.properties
。您必须将以下几行放入该文件中,例如:有关其他日志记录框架和详细信息,请参阅 < a href="http://ibatisnet.sourceforge.net/DevGuide.html#d0e2600" rel="nofollow noreferrer">此链接
It's posible to show this information.iBatis uses some the Logging framework including
Log4J
.To use
Log4J
create filelog4j.properties
in the class path.You've to put the next lines in the file for example:For other logging framework and detail info see this link
从
SqlSessionFactory
获取Configuration
对象,然后:Get the
Configuration
object from yourSqlSessionFactory
, then:我的参考:https://www.java2s.com/Open-Source/Java-Document-2/UnTagged/gmc/com/gm/common/orm/mybatis/plugin/OffsetLimitInterceptor.java.htm
My reference : https://www.java2s.com/Open-Source/Java-Document-2/UnTagged/gmc/com/gm/common/orm/mybatis/plugin/OffsetLimitInterceptor.java.htm
大多数 SQL 引擎允许您“记录”执行的所有查询(通常还包括有关查询所用时间、返回结果数量等信息)。您是否有权访问引擎的日志,并且可以配置它以便它记录您需要的所有内容吗?
Most SQL engines allow you to "log" all the queries executed (typically together with information about the time the query took, the number of results it returned, and the like). Do you have access to your engine's logs, and can you configure it so it will log all you need?
您可以使用 p6spy 或 jdbcdslog 为此。
You can use p6spy or jdbcdslog for that.