moved hibernate batch insert examples from spring-data-jpa-2 to spring-data-jpa-3
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
- [Spring Data JPA Delete and Relationships](https://www.baeldung.com/spring-data-jpa-delete)
|
||||
- [Spring Data JPA and Named Entity Graphs](https://www.baeldung.com/spring-data-jpa-named-entity-graphs)
|
||||
|
||||
- [Batch Insert/Update with Hibernate/JPA](https://www.baeldung.com/jpa-hibernate-batch-insert-update)
|
||||
- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush)
|
||||
- [Derived Query Methods in Spring Data JPA Repositories](https://www.baeldung.com/spring-data-derived-queries)
|
||||
- [LIKE Queries in Spring JPA Repositories](https://www.baeldung.com/spring-jpa-like-queries)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
- [DB Integration Tests with Spring Boot and Testcontainers](https://www.baeldung.com/spring-boot-testcontainers-integration-test)
|
||||
- [Spring Data JPA @Modifying Annotation](https://www.baeldung.com/spring-data-jpa-modifying-annotation)
|
||||
- [Spring Data JPA Batch Inserts](https://www.baeldung.com/spring-data-jpa-batch-inserts)
|
||||
- [Batch Insert/Update with Hibernate/JPA](https://www.baeldung.com/jpa-hibernate-batch-insert-update)
|
||||
|
||||
### Eclipse Config
|
||||
After importing the project into Eclipse, you may see the following error:
|
||||
|
||||
@@ -55,11 +55,18 @@
|
||||
<version>${postgresql.version}</version>
|
||||
</dependency>
|
||||
<!-- Test containers only dependencies -->
|
||||
|
||||
<dependency>
|
||||
<groupId>net.ttddyy</groupId>
|
||||
<artifactId>datasource-proxy</artifactId>
|
||||
<version>${datasource-proxy.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<guava.version>21.0</guava.version>
|
||||
<testcontainers.postgresql.version>1.10.6</testcontainers.postgresql.version>
|
||||
<postgresql.version>42.2.5</postgresql.version>
|
||||
<datasource-proxy.version>1.4.1</datasource-proxy.version>
|
||||
</properties>
|
||||
</project>
|
||||
@@ -2,10 +2,12 @@ package com.baeldung.boot;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableJpaRepositories
|
||||
@EnableJpaRepositories("com.baeldung")
|
||||
@EntityScan("com.baeldung")
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -3,12 +3,12 @@ package com.baeldung.batchinserts;
|
||||
import static com.baeldung.batchinserts.TestObjectHelper.createSchool;
|
||||
import static com.baeldung.batchinserts.TestObjectHelper.createStudent;
|
||||
|
||||
import com.baeldung.batchinserts.model.School;
|
||||
import com.baeldung.batchinserts.model.Student;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -17,8 +17,12 @@ import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.baeldung.batchinserts.model.School;
|
||||
import com.baeldung.batchinserts.model.Student;
|
||||
import com.baeldung.boot.Application;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@Transactional
|
||||
@ActiveProfiles("batchinserts")
|
||||
public class JpaBatchInsertsIntegrationTest {
|
||||
@@ -3,6 +3,8 @@ package com.baeldung.batchinserts;
|
||||
import static com.baeldung.batchinserts.TestObjectHelper.createSchool;
|
||||
|
||||
import com.baeldung.batchinserts.model.School;
|
||||
import com.baeldung.boot.Application;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import org.junit.After;
|
||||
@@ -15,7 +17,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@Transactional
|
||||
@ActiveProfiles("batchinserts")
|
||||
@TestPropertySource(properties = "spring.jpa.properties.hibernate.jdbc.batch_size=-1")
|
||||
Reference in New Issue
Block a user