gpt4 book ai didi

java - 使用日志工具记录 HQL 返回值时遇到问题

转载 作者:行者123 更新时间:2023-11-29 19:09:00 25 4
gpt4 key购买 nike

我正在尝试记录 HQL 的返回值,并按照以下说明进行操作: https://www.mkyong.com/hibernate/how-to-display-hibernate-sql-parameter-values-solution/

我能够使用 1.1 来查看 Eclipse 上的返回值。但是,当我使用 mvn build 并运行它时,我得到:

INFO: HHH000046: Connection properties: {user=root, password=****}
Failed to create sessionFactory object.java.lang.NullPointerException
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ExceptionInInitializerError
at foo.bar.Main.main(Main.java:36)
... 6 more
Caused by: java.lang.NullPointerException
at com.p6spy.engine.spy.P6SpyDriverCore.connect(P6SpyDriverCore.java:371)..

我尝试使用 1.3 但看到:错误:无法找到接受 jdbc:p6spy:mysql://localhost:3306/testdb 的驱动程序

我使用了 deregistered=true 但这不起作用。

现在,如果我使用下面的版本就可以了:

<dependency>
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
<version>2.1.4</version>
</dependency>

但是,当我运行我的程序时,我看到:1491427383465|37|语句|连接0|选择person0_.personid作为...1491427383494|0|语句|连接0|选择项目0...

如何获取返回值?我在这里迷路了......

最佳答案

P6Spy 的默认设置是不包含返回值。您可以通过在spy.properties 中添加或更新以下行来启用此功能。

#list of categories to exclude: error, info, batch, debug, statement,
#commit, rollback and result are valid values
# (default is info,debug,result,resultset,batch)
excludecategories=info,debug,result,batch

spy.properties 的完整文档以及提供配置的其他方法位于 http://p6spy.readthedocs.io/en/latest/configandusage.html .

关于java - 使用日志工具记录 HQL 返回值时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43242317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com