Closed tianyu94 closed 2 years ago
左边rerun按钮点一下试试
试过的,重启应用也不行,必须重启ide,但是还是会出现这个问题。最开始我用了grep console 插件,那个时候都不行,卸载后就可以了,但是就出现这个情况了。有方法开启插件的日志么,我给你日志分析
在 2022年4月22日,17:58,ob @.***> 写道:
左边rerun按钮点一下试试
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.
出问题的时候grep console这个开启吗?感觉可能会互相影响到,你先关掉试下。。
就是关了的,也卸载了的,卸载后也有问题
在 2022年4月22日,18:13,ob @.***> 写道:
出问题的时候grep console这个开启吗?感觉可能会互相影响到,你先关掉试下。。
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.
这暂时有点没头绪,你打印不出来的时,帮忙把控制台的日志贴一下。插件是否最新版本的?
2022-04-24 08:55:38.582 DEBUG 23840 --- [nio-8030-exec-1] org.hibernate.SQL : select cast(sum(cast(case when aiccmsginf0_.state in (? , ?) then ? else ? end as signed)) as signed) as col_0_0_ from aicc_msg_info_record aiccmsginf0_ where aiccmsginf0_.created_date>? and aiccmsginf0_.created_date<? and aiccmsginf0_.sys_tenant_id=?
2022-04-24 08:55:38.582 TRACE 23840 --- [nio-8030-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [INTEGER] - [4]
2022-04-24 08:55:38.582 TRACE 23840 --- [nio-8030-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [INTEGER] - [2]
2022-04-24 08:55:38.582 TRACE 23840 --- [nio-8030-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [3] as [INTEGER] - [1]
2022-04-24 08:55:38.582 TRACE 23840 --- [nio-8030-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [4] as [INTEGER] - [0]
2022-04-24 08:55:38.583 TRACE 23840 --- [nio-8030-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [5] as [TIMESTAMP] - [2022-04-23T00:00]
2022-04-24 08:55:38.583 TRACE 23840 --- [nio-8030-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [6] as [TIMESTAMP] - [2022-04-23T23:59:59]
2022-04-24 08:55:38.584 TRACE 23840 --- [nio-8030-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [7] as [BIGINT] - [928929552363687936]
最新的,而且有个问题,我是最新的 SpringBoot 2.6.6,这个配置 show-sql: true
似乎不起作用,我是通过 org.hibernate.SQL: debug
将原始 SQL 打印出来的,JPA SQL 插件的 Preparing 配置是
org.hibernate.SQL :
在插件的settings里面配置,你看下Preparing,把默认的改成你的前缀上面的前缀试下。
是这样的,刚才又是打印到 20 个 SQL 就没打印了
能打印的20个SQL也是上面的前缀吗?
我改成org.hibernate.SQL :
是可以打印了。
你查下sql日志的前缀有没有变化
日志较多,你看下这个吧,重启 IDE 再启动应用,分别是 Spring 的日志和 JPA SQL 的。
出现这种情况后,我只有重启 IDE 后能打印一部分格式化SQL,重启前点那个 rerun 也不行
文件应该是 md 格式的,改错了
谢谢,过后我排查下
大概原因知道了,从后面开始,你代码里面有多线程的日志输出,导致解析混乱出错了。 这个解决起来会麻烦些。
应该不存在完全同步的系统吧,多个请求时肯定会出现并发。
解析 SQL 语句的时候,通过正则匹配一个 query 或 update
比如配置为正则:
.*([.*]) org.hibernate.SQL :
相关的日志通过 Matcher group 进行关联,比如这种情况可以根据线程名称作为关联的key,如其他的情况也可以自己配置多个 group,反正组合一起的就当做一个查询(select + parameters)
log示例:
2022-04-24 08:55:38.582 DEBUG 23840 --- [nio-8030-exec-1] org.hibernate.SQL : select cast(sum(cast(case when aiccmsginf0_.state in (? , ?) then ? else ? end as signed)) as signed) as col_0_0_ from aicc_msg_info_record aiccmsginf0_ where aiccmsginf0_.created_date>? and aiccmsginf0_.created_date<? and aiccmsginf0_.sys_tenant_id=?
2022-04-24 08:55:38.582 TRACE 23840 --- [nio-8030-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [INTEGER] - [4]
第1行匹配出: nio-8030-exec-1
, select ...
第2行匹配出: nio-8030-exec-1
, [1] as [INTEGER] - [4]
然后根据匹配的 group 分发给独立的解析器,这样每个线程的日志顺序肯定能保证,然后并发下也不会受到其他线程输出的干扰
嗯,跟我的想法一样,下个版本会解决。
@tianyu94 最新版本已经可以更新,再试下看看: https://plugins.jetbrains.com/plugin/15242-jpa-sql/versions
可以了,厉害了我的bro,你是我的神
IDE:
比如这个,我用 Text 标签的功能倒是可以,
我的配置:
preparing:
parameters:
binding parameter