Spring on Glassfish - 记录 Hibernate 参数?

发布于 2024-12-28 09:26:43 字数 306 浏览 2 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

眼泪淡了忧伤 2025-01-04 09:26:43

似乎唯一的答案是让 Glassfish 使用 log4j。

本文介绍了具体方法

Seems like the only answer is to have Glassfish use log4j.

This article describes how.

你是年少的欢喜 2025-01-04 09:26:43

看一下 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

时光暖心i 2025-01-04 09:26:43

打开您的 spring bean 配置文件。这是配置 hibernate 会话工厂的地方(通常在 hibernate.cfg.xml 中)

查找以下性质的 bean 定义。请注意,可以在单独的配置文件中定义它们。

<bean id="mySessionFactory" 
class="org.springframework.orm.hibernate3....

这是您需要将属性 show_sqlformat_sql 设置为 true 的地方。

另外,找到项目的 log4j 配置(或在 glassfish 控制台中)并引入以下设置:

log4j.logger.org.hibernate.SQL=debug 
log4j.logger.org.hibernate.type=trace 

更多详细信息 此处此处此处

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.

<bean id="mySessionFactory" 
class="org.springframework.orm.hibernate3....

This is the place where you need to set properties show_sql and format_sql to true.

Also, locate your project's log4j configuration (or in glassfish console) and introduce following settings:

log4j.logger.org.hibernate.SQL=debug 
log4j.logger.org.hibernate.type=trace 

More details here, here and here

长亭外,古道边 2025-01-04 09:26:43

Glassfish 管理控制台 ->配置->服务器配置->记录器设置->日志级别->添加记录器-> org.hibernate.type :最好的

Glassfish 记录器设置

来源: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

Glassfish logger settings

source : https://cumacakmak.wordpress.com/2015/01/18/glassfish-hibernate-binding-parameters-easy-way/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文