Spring on Glassfish - 记录 Hibernate 参数?
我有一个 Spring 应用程序在 Glassfish Web 服务器上运行,我在休眠查询中看到一些非常奇怪的行为。我希望能够看到查询及其参数,而不仅仅是“?”占位符。我该怎么做?
我尝试通过管理控制台进入,在服务器配置
- javax.enterprise.system.std.com.sun.enterprise.server.logging
- log4j.logger.org.hibernate.type
中添加并配置以下记录器到“FINEST”我仍然没有得到参数绑定。
我该怎么做?
I have a Spring application running on the Glassfish Webserver and I'm seeing some very strange behavior in hibernate queries. I would like to be able to see the query AND its parameters, not just the '?' placeholder. How do I do this?
I have tried going in through the admin console, adding and configuring the following loggers to 'FINEST' in the server config
- javax.enterprise.system.std.com.sun.enterprise.server.logging
- log4j.logger.org.hibernate.type
I'm still not getting the parameter binding.
How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
似乎唯一的答案是让 Glassfish 使用 log4j。
本文介绍了具体方法。
Seems like the only answer is to have Glassfish use log4j.
This article describes how.
看一下 p6spy,它是一个介于 Hibernate 和真实 JDBC 提供程序之间并记录 sql 语句的 JDBC 提供程序。
我还没有在 Glassfish 上尝试过,但请查看本教程:http://blogs.oracle。 com/enterprisetechtips/entry/using_p6spy_and_the_glassfish
Take a look at p6spy, a JDBC provider going in between Hibernate and your real JDBC provider and logging sql statements.
I haven't tried it on Glassfish, but check out this tutorial: http://blogs.oracle.com/enterprisetechtips/entry/using_p6spy_and_the_glassfish
打开您的 spring bean 配置文件。这是配置 hibernate 会话工厂的地方(通常在 hibernate.cfg.xml 中)
查找以下性质的 bean 定义。请注意,可以在单独的配置文件中定义它们。
这是您需要将属性
show_sql
和format_sql
设置为 true 的地方。另外,找到项目的 log4j 配置(或在 glassfish 控制台中)并引入以下设置:
更多详细信息 此处、此处 和 此处
Open your spring bean configuration file. That is the place where you would configure hibernate session factory (what generally goes in
hibernate.cfg.xml
)Look for the
bean
definition of following nature. Note that it is possible to define these in a separate configuration file.This is the place where you need to set properties
show_sql
andformat_sql
to true.Also, locate your project's log4j configuration (or in glassfish console) and introduce following settings:
More details here, here and here
Glassfish 管理控制台 ->配置->服务器配置->记录器设置->日志级别->添加记录器-> org.hibernate.type :最好的
来源:https://cumacakmak.wordpress.com/2015/01/18/glassfish-hibernate-binding-parameters-easy-way/
Glassfish admin console -> Configurations -> Server-config -> Logger Settings -> Log levels -> Add Logger -> org.hibernate.type : FINEST
source : https://cumacakmak.wordpress.com/2015/01/18/glassfish-hibernate-binding-parameters-easy-way/