How to display hibernate sql parameter values – Log4j
来源:互联网 发布:excel多个数据求和 编辑:程序博客网 时间:2024/05/21 04:41
Problem
Hibernate has basic logging feature to display the SQL generated statement with show_sql configuration property.
Hibernate: INSERT INTO mkyong.stock_transaction (CHANGE, CLOSE, DATE, OPEN, STOCK_ID, VOLUME)VALUES (?, ?, ?, ?, ?, ?)
However , it just isn’t enough for debugging, the Hibernate SQL parameter values are missing.
Solution – Log4jLog4J is required to display the real Hibernate SQL parameter value.
1. Configure the Log4j in Hibernate
Follow this article to configure Log4j in Hibernate
2. Change the Log level
Modify the Log4j properties file, and change the log level to “debug” or “trace” in “log4j.logger.org.hibernate.type” property.
File : log4j.properties
# Direct log messages to stdoutlog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.Target=System.outlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n# Root logger optionlog4j.rootLogger=INFO, stdout# Hibernate logging options (INFO only shows startup messages)log4j.logger.org.hibernate=INFO# Log JDBC bind parameter runtime argumentslog4j.logger.org.hibernate.type=trace
3. Done
The Hibernate real parameter values are display now
Output…
Hibernate: INSERT INTO mkyong.stock_transaction (CHANGE, CLOSE, DATE, OPEN, STOCK_ID, VOLUME)VALUES (?, ?, ?, ?, ?, ?)13:33:07,253 DEBUG FloatType:133 - binding '10.0' to parameter: 113:33:07,253 DEBUG FloatType:133 - binding '1.1' to parameter: 213:33:07,253 DEBUG DateType:133 - binding '30 December 2009' to parameter: 313:33:07,269 DEBUG FloatType:133 - binding '1.2' to parameter: 413:33:07,269 DEBUG IntegerType:133 - binding '11' to parameter: 513:33:07,269 DEBUG LongType:133 - binding '1000000' to parameter: 6
阅读全文
0 0
- How to display hibernate sql parameter values – Log4j
- How to display hibernate sql parameter values – Log4j
- Demonstrates how to display values as an SAP dropdown listbox.
- How to display a byte array as hex values
- How to display column values in a single cell in Web Intelligence using Oracle database ?
- FND: Function Parameter How-to
- how to show hidden parameter
- Linq to SQL how to do “where [column] in (list of values)”
- How to display a Variable ?
- How to display error messages?
- How To Auto Complete With Custom Values
- How to store CGRect values in NSMutableArray?
- How to retrieve checkboxes values in jQuery
- how to resolve "key values mismatch" issue
- How to Detect HTTP Parameter Pollution Attacks
- How to configure the kernel parameter "console"
- How to get method parameter names?
- Hibernate how to(一)
- linux RWX权限的解读
- $.parseJSON() 函数用于将符合标准格式的的JSON字符串转为与之对应的JavaScript对象。
- android性能优化
- 记一次修改系统时间后,Linux重启磁盘superblock不一致故障fsck恢复
- RecycleView的使用总结(需要在gradle中添加依赖)
- How to display hibernate sql parameter values – Log4j
- Linux下 FFmpeg 编译安装
- 电力101/104规约文件服务报文浅析
- 微信小程序登录数据解密以及状态维持
- html5桌面通知 提示
- 区别:指针常量、指针变量、常量指针和常量指针常量
- enqueue_task和dequeue_task源码分析
- [RK3288][Android6.0] 调试笔记 --- touch无法获取坐标点
- JQ多个表单必填 否则弹出提示 完善必填信息