We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
那么当saveAndFlush之后虽然事务没有提交,但是依然可以拿到mysql的自增的ID值,因为save的sql已经到mysql里面执行了。
我们首先打开jpq和mysql的jdbc驱动的日志:
1. datasource的url上面添加:&logger=Slf4JLogger&profileSQL=true 如下: url: jdbc:mysql://192.168.3.10:3306/hephaestus_dev?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&logger=Slf4JLogger&profileSQL=true 2. 开启jdbc,hibernate的sql日志: logging: level: org.springframework.jdbc.core.JdbcTemplate: DEBUG org.springframework.jdbc.core.StatementCreatorUtils: TRACE com.zaxxer.hikari.HikariConfig: DEBUG com.zaxxer.hikari: TRACE org.hibernate.SQL: trace org.hibernate.type: descriptor: sql: BasicBinder: trace
测试代码如下: 日志如下: debug的过程: 我们看到有一个ok_packet对象,找一下官方文档: 参考:https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_ok_packet.html 也就是说JDBC的驱动包里面已经在报文里面给了insert之后产生的自增的ID了。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
那么当saveAndFlush之后虽然事务没有提交,但是依然可以拿到mysql的自增的ID值,因为save的sql已经到mysql里面执行了。
我们首先打开jpq和mysql的jdbc驱动的日志:
测试代码如下:
日志如下:
debug的过程:
我们看到有一个ok_packet对象,找一下官方文档:
参考:https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_ok_packet.html
也就是说JDBC的驱动包里面已经在报文里面给了insert之后产生的自增的ID了。
The text was updated successfully, but these errors were encountered: