我在调试 SQL 查询时遇到问题。我尝试配置以下设置以启用查询调试,但尚未成功。
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.format_sql=true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
logging.level.org.hibernate.type=TRACE
这是我的 Hibernate 输出。正如您所看到的,没有提供与“token”和“is_active”相对应的值。
Hibernate:
select
c1_0.id,
c1_0.bussiness_name,
c1_0.is_active,
c1_0.token
from
credential c1_0
where
c1_0.token=?
and c1_0.is_active
此外,这些配置在 Java 11 和 MySQL 上完美无缺。但是,我很困惑什么可能导致 PostgreSQL 15 和 Java 21 出现问题。
我解决了问题,同时用
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
替换
logging.level.org.hibernate.orm.jdbc.bind=TRACE