Skip to content

Commit 4b1c59b

Browse files
committed
Batch inserts in Spring style and batch per transaction
1 parent ae5ab2b commit 4b1c59b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

HibernateSpringBootBatchInsertsSpringStyleBatchPerTransaction/src/main/java/com/bookstore/impl/BatchRepositoryImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import javax.persistence.EntityManager;
66
import org.springframework.data.jpa.repository.support.JpaEntityInformation;
77
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
8+
import org.springframework.transaction.annotation.Propagation;
89
import org.springframework.transaction.annotation.Transactional;
910

10-
@Transactional(readOnly = true)
11+
@Transactional(propagation = Propagation.NEVER)
1112
public class BatchRepositoryImpl<T, ID extends Serializable>
1213
extends SimpleJpaRepository<T, ID> implements BatchRepository<T, ID> {
1314

HibernateSpringBootBatchInsertsSpringStyleBatchPerTransaction/src/main/resources/application.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ spring.datasource.username=root
33
spring.datasource.password=root
44

55
spring.jpa.hibernate.ddl-auto=create
6-
spring.jpa.show-sql=true
6+
spring.jpa.show-sql=false
77

88
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
99

@@ -17,3 +17,8 @@ spring.jpa.properties.hibernate.cache.use_second_level_cache=false
1717
# spring.jpa.properties.hibernate.order_inserts=true
1818

1919
spring.jpa.properties.hibernate.generate_statistics=true
20+
21+
logging.level.ROOT=INFO
22+
logging.level.org.hibernate.engine.transaction.internal.TransactionImpl=DEBUG
23+
logging.level.org.springframework.orm.jpa=DEBUG
24+
logging.level.org.springframework.transaction=DEBUG

0 commit comments

Comments
 (0)