私は700K +レコードでExcelファイルを読み込み、バッチをMySQLデータベーステーブルに挿入しようとしています。バネデータJPAバッチ挿入が非常に遅い
Excelの解析は高速で、エンティティオブジェクトはArrayList
に50秒以内に取得できますのでご注意ください。
私はSpring Boot JPAを使用しています。以下は
私の部分application.properties
ファイルです:
hibernate.jdbc.batch_size=1000
spring.jpa.hibernate.use-new-id-generator-mappings=true
と私の部分Entity class
:
@Entity
@Table(name = "WHT_APPS", schema = "TEST")
public class WHTApps {
@Id
@TableGenerator(name = "whtAppsGen", table = "ID_GEN", pkColumnName = "GEN_KEY", valueColumnName = "GEN_VAL")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "whtAppsGen")
private Long id;
@Column(name = "VENDOR_CODE")
private int vendorCode;
.
.
.
.
私DAO
です:
@Repository
@Transactional
public class JapanWHTDaoImpl implements JapanWHTDao {
@Autowired
JapanWHTAppsRepository appsRepo;
@Override
public void storeApps(List<WHTApps> whtAppsList) {
appsRepo.save(whtAppsList);
}
以下Repository
クラスです:
@Transactional
public interface JapanWHTAppsRepository extends JpaRepository<WHTApps, Long> {
}
私がここで間違っていることを教えてもらえますか?
EDIT:
プロセスが終了し、最終的にエラーをスローしません: -
2017-08-15 15:15:24.516 WARN 14710 --- [tp1413491716-17] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 08S01
2017-08-15 15:15:24.516 ERROR 14710 --- [tp1413491716-17] o.h.engine.jdbc.spi.SqlExceptionHelper : Communications link failure
The last packet successfully received from the server was 107,472 milliseconds ago. The last packet sent successfully to the server was 107,472 milliseconds ago.
2017-08-15 15:15:24.518 INFO 14710 --- [tp1413491716-17] o.h.e.j.b.internal.AbstractBatchImpl : HHH000010: On release of batch it still contained JDBC statements
2017-08-15 15:15:24.525 WARN 14710 --- [tp1413491716-17] c.m.v.c3p0.impl.DefaultConnectionTester : SQL State '08007' of Exception tested by statusOnException() implies that the database is invalid, and the pool should refill itself with fresh Connections.
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.43.jar:5.1.43]
.
.
.
.
2017-08-15 15:15:24.526 WARN 14710 --- [tp1413491716-17] c.m.v2.c3p0.impl.NewPooledConnection : [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
2017-08-15 15:15:24.527 WARN 14710 --- [tp1413491716-17] c.m.v2.c3p0.impl.NewPooledConnection : [c3p0] Another error has occurred [ com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown. ] which will not be reported to listeners!
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
おかげ
ハイバネートマニュアルには、バッチインサートを高速化する方法を説明するセクションがあります。 –
あなたは私を特定の場所に向けることができますか? –
目次には、「バッチ処理」または「バッチ処理」があります。 Ctrl-Fはあなたの友人です。 http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#batch –