Open zhangzhenhuajack opened 3 years ago
spring.jpa.properties.hibernate.jdbc.batch_size=100
spring.jpa.properties.hibernate.order_inserts=true
The first property tells Hibernate to collect inserts in batches of four. The order_inserts property tells Hibernate to take the time to group inserts by entity, creating larger batches.
同时需要注意控制好事务大小
开启监控
spring.jpa.properties.hibernate.generate_statistics=true
16577314 nanoseconds spent preparing 100 JDBC statements;
2207548 nanoseconds spent executing 100 JDBC statements;
2003005 nanoseconds spent executing 1 JDBC batches;
第一步实体 implements Persistable, Serializable
第二步重写 isNew方法即可;
参考如下实体:
当新增UserGoldJoursShard对象的时候设置defaultNew=true,调用实例如下: