Merge remote-tracking branch 'upstream/master'

This commit is contained in:
andrebrowne
2020-08-08 19:49:42 -04:00
513 changed files with 5353 additions and 1794 deletions
@@ -1,6 +1,9 @@
package com.baeldung.jdbc;
import static org.junit.Assert.*;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.sql.CallableStatement;
import java.sql.Connection;
@@ -16,10 +19,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class JdbcLiveTest {
@@ -33,10 +34,11 @@ public class JdbcLiveTest {
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/myDb?noAccessToProcedureBodies=true", "user1", "pass");
Statement stmt = con.createStatement();
try (Statement stmt = con.createStatement()) {
String tableSql = "CREATE TABLE IF NOT EXISTS employees (emp_id int PRIMARY KEY AUTO_INCREMENT, name varchar(30), position varchar(30), salary double)";
stmt.execute(tableSql);
String tableSql = "CREATE TABLE IF NOT EXISTS employees (emp_id int PRIMARY KEY AUTO_INCREMENT, name varchar(30), position varchar(30), salary double)";
stmt.execute(tableSql);
}
}
@@ -101,10 +103,8 @@ public class JdbcLiveTest {
@Test
public void whenCallProcedure_thenCorrect() {
try {
String preparedSql = "{call insertEmployee(?,?,?,?)}";
CallableStatement cstmt = con.prepareCall(preparedSql);
String preparedSql = "{call insertEmployee(?,?,?,?)}";
try (CallableStatement cstmt = con.prepareCall(preparedSql)) {
cstmt.setString(2, "ana");
cstmt.setString(3, "tester");
cstmt.setDouble(4, 2000);
@@ -121,9 +121,10 @@ public class JdbcLiveTest {
public void whenReadMetadata_thenCorrect() throws SQLException {
DatabaseMetaData dbmd = con.getMetaData();
ResultSet tablesResultSet = dbmd.getTables(null, null, "%", null);
while (tablesResultSet.next()) {
LOG.info(tablesResultSet.getString("TABLE_NAME"));
try (ResultSet tablesResultSet = dbmd.getTables(null, null, "%", null)) {
while (tablesResultSet.next()) {
LOG.info(tablesResultSet.getString("TABLE_NAME"));
}
}
String selectSql = "SELECT * FROM employees";
+1 -1
View File
@@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>flyway</artifactId>
<artifactId>flyway-repair</artifactId>
<name>flyway-repair</name>
<packaging>jar</packaging>
<description>Flyway Repair Demo</description>
@@ -57,6 +57,8 @@ public class PhoneNumberType implements UserType {
if (Objects.isNull(value)) {
st.setNull(index, Types.INTEGER);
st.setNull(index+1, Types.INTEGER);
st.setNull(index+2, Types.INTEGER);
} else {
PhoneNumber employeeNumber = (PhoneNumber) value;
st.setInt(index,employeeNumber.getCountryCode());
+11 -6
View File
@@ -19,7 +19,7 @@
<module>core-java-persistence</module>
<module>deltaspike</module>
<module>elasticsearch</module>
<module>flyway</module>
<module>flyway-repair</module>
<module>hbase</module>
<module>hibernate5</module>
<module>hibernate-mapping</module> <!-- long running -->
@@ -59,11 +59,16 @@
<module>spring-data-elasticsearch</module>
<module>spring-data-gemfire</module>
<module>spring-data-geode</module>
<module>spring-data-jpa</module>
<module>spring-data-jpa-2</module>
<module>spring-data-jpa-3</module>
<module>spring-data-jpa-4</module>
<module>spring-data-jpa-5</module>
<module>spring-data-jpa-annotations</module>
<module>spring-data-jpa-crud</module>
<module>spring-data-jpa-enterprise</module>
<module>spring-data-jpa-filtering</module>
<module>spring-data-jpa-query</module>
<module>spring-data-jpa-repo</module>
<module>spring-data-jdbc</module>
<module>spring-data-keyvalue</module>
<module>spring-data-mongodb</module>
<module>spring-data-neo4j</module>
@@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-2</relativePath>
</parent>
<artifactId>spring-data-jdbc</artifactId>
<name>spring-data-jdbc</name>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,59 @@
package com.baeldung.springdatajdbcintro;
import java.util.Optional;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.baeldung.springdatajdbcintro.entity.Person;
import com.baeldung.springdatajdbcintro.repository.PersonRepository;
import ch.qos.logback.classic.Logger;
@SpringBootApplication
public class Application implements CommandLineRunner {
private static final Logger LOGGER = (Logger) LoggerFactory.getLogger(Application.class);
@Autowired
private PersonRepository repository;
@Autowired
private DatabaseSeeder dbSeeder;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public void run(String... arg0) throws Exception {
LOGGER.info("@@ Inserting Data....");
dbSeeder.insertData();
LOGGER.info("@@ findAll() call...");
repository.findAll()
.forEach(person -> LOGGER.info(person.toString()));
LOGGER.info("@@ findById() call...");
Optional<Person> optionalPerson = repository.findById(1L);
optionalPerson.ifPresent(person -> LOGGER.info(person.toString()));
LOGGER.info("@@ save() call...");
Person newPerson = new Person("Franz", "Kafka");
Person result = repository.save(newPerson);
LOGGER.info(result.toString());
LOGGER.info("@@ delete");
optionalPerson.ifPresent(person -> repository.delete(person));
LOGGER.info("@@ findAll() call...");
repository.findAll()
.forEach(person -> LOGGER.info(person.toString()));
LOGGER.info("@@ findByFirstName() call...");
repository.findByFirstName("Franz")
.forEach(person -> LOGGER.info(person.toString()));
LOGGER.info("@@ findByFirstName() call...");
repository.updateByFirstName(2L, "Date Inferno");
repository.findAll()
.forEach(person -> LOGGER.info(person.toString()));
}
}
@@ -0,0 +1,26 @@
package com.baeldung.springdatajdbcintro;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import ch.qos.logback.classic.Logger;
@Component
public class DatabaseSeeder {
private static final Logger LOGGER = (Logger) LoggerFactory.getLogger(DatabaseSeeder.class);
@Autowired
private JdbcTemplate jdbcTemplate;
public void insertData() {
LOGGER.info("> Inserting data...");
jdbcTemplate.execute("INSERT INTO Person(first_name,last_name) VALUES('Victor', 'Hygo')");
jdbcTemplate.execute("INSERT INTO Person(first_name,last_name) VALUES('Dante', 'Alighieri')");
jdbcTemplate.execute("INSERT INTO Person(first_name,last_name) VALUES('Stefan', 'Zweig')");
jdbcTemplate.execute("INSERT INTO Person(first_name,last_name) VALUES('Oscar', 'Wilde')");
}
}
@@ -0,0 +1,57 @@
package com.baeldung.springdatajdbcintro.entity;
import org.springframework.data.annotation.Id;
public class Person {
@Id
private long id;
private String firstName;
private String lastName;
public Person() {
super();
}
public Person(long id, String firstName, String lastName) {
super();
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
return "Person [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + "]";
}
}
@@ -0,0 +1,23 @@
package com.baeldung.springdatajdbcintro.repository;
import java.util.List;
import org.springframework.data.jdbc.repository.query.Modifying;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.baeldung.springdatajdbcintro.entity.Person;
@Repository
public interface PersonRepository extends CrudRepository<Person,Long> {
@Query("select * from person where first_name=:firstName")
List<Person> findByFirstName(@Param("firstName") String firstName);
@Modifying
@Query("UPDATE person SET first_name = :name WHERE id = :id")
boolean updateByFirstName(@Param("id") Long id, @Param("name") String name);
}
@@ -0,0 +1,8 @@
#H2 DB
spring.jpa.hibernate.ddl-auto=none
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:persondb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=test
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
@@ -0,0 +1,5 @@
create table person (
id integer identity primary key,
first_name varchar(30),
last_name varchar(30)
);
@@ -1,12 +0,0 @@
### Relevant Articles:
- [Spring Data JPA Derived Delete Methods](https://www.baeldung.com/spring-data-jpa-deleteby)
- [JPA Join Types](https://www.baeldung.com/jpa-join-types)
- [Case Insensitive Queries with Spring Data Repository](https://www.baeldung.com/spring-data-case-insensitive-queries)
- [The Exists Query in Spring Data](https://www.baeldung.com/spring-data-exists-query)
- [Spring Data JPA Repository Populators](https://www.baeldung.com/spring-data-jpa-repository-populators)
- [Spring Data JPA and Null Parameters](https://www.baeldung.com/spring-data-jpa-null-parameters)
- [Spring Data JPA Projections](https://www.baeldung.com/spring-data-jpa-projections)
- [JPA @Embedded And @Embeddable](https://www.baeldung.com/jpa-embedded-embeddable)
- [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)
- [Customizing the Result of JPA Queries with Aggregation Functions](https://www.baeldung.com/jpa-queries-custom-result-with-aggregation-functions)
@@ -1,42 +0,0 @@
package com.baeldung.model;
import javax.persistence.*;
import java.util.Set;
@Entity
@Table(name = "users")
public class BasicUser {
@Id
@GeneratedValue
private Long id;
private String username;
@ElementCollection
private Set<String> permissions;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Set<String> getPermissions() {
return permissions;
}
public void setPermissions(Set<String> permissions) {
this.permissions = permissions;
}
}
@@ -1,13 +0,0 @@
package com.baeldung.multipledb.dao.product;
import java.util.List;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.baeldung.multipledb.model.product.Product;
public interface ProductRepository extends PagingAndSortingRepository<Product, Integer> {
List<Product> findAllByPrice(double price, Pageable pageable);
}
@@ -1,14 +0,0 @@
package com.baeldung.repository;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import com.baeldung.model.BasicUser;
public interface UserRepository extends JpaRepository<BasicUser, Long> {
Optional<BasicUser> findSummaryByUsername(String username);
Optional<BasicUser> findByUsername(String username);
}
@@ -1,142 +0,0 @@
package com.baeldung.multipledb;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import com.baeldung.multipledb.dao.product.ProductRepository;
import com.baeldung.multipledb.model.product.Product;
@RunWith(SpringRunner.class)
@SpringBootTest(classes=MultipleDbApplication.class)
@EnableTransactionManagement
public class ProductRepositoryIntegrationTest {
@Autowired
private ProductRepository productRepository;
@Before
@Transactional("productTransactionManager")
public void setUp() {
productRepository.save(Product.from(1001, "Book", 21));
productRepository.save(Product.from(1002, "Coffee", 10));
productRepository.save(Product.from(1003, "Jeans", 30));
productRepository.save(Product.from(1004, "Shirt", 32));
productRepository.save(Product.from(1005, "Bacon", 10));
}
@Test
public void whenRequestingFirstPageOfSizeTwo_ThenReturnFirstPage() {
Pageable pageRequest = PageRequest.of(0, 2);
Page<Product> result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(2));
assertTrue(result.stream()
.map(Product::getId)
.allMatch(id -> Arrays.asList(1001, 1002)
.contains(id)));
}
@Test
public void whenRequestingSecondPageOfSizeTwo_ThenReturnSecondPage() {
Pageable pageRequest = PageRequest.of(1, 2);
Page<Product> result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(2));
assertTrue(result.stream()
.map(Product::getId)
.allMatch(id -> Arrays.asList(1003, 1004)
.contains(id)));
}
@Test
public void whenRequestingLastPage_ThenReturnLastPageWithRemData() {
Pageable pageRequest = PageRequest.of(2, 2);
Page<Product> result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(1));
assertTrue(result.stream()
.map(Product::getId)
.allMatch(id -> Arrays.asList(1005)
.contains(id)));
}
@Test
public void whenSortingByNameAscAndPaging_ThenReturnSortedPagedResult() {
Pageable pageRequest = PageRequest.of(0, 3, Sort.by("name"));
Page<Product> result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(3));
assertThat(result.getContent()
.stream()
.map(Product::getId)
.collect(Collectors.toList()), equalTo(Arrays.asList(1005, 1001, 1002)));
}
@Test
public void whenSortingByPriceDescAndPaging_ThenReturnSortedPagedResult() {
Pageable pageRequest = PageRequest.of(0, 3, Sort.by("price")
.descending());
Page<Product> result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(3));
assertThat(result.getContent()
.stream()
.map(Product::getId)
.collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001)));
}
@Test
public void whenSortingByPriceDescAndNameAscAndPaging_ThenReturnSortedPagedResult() {
Pageable pageRequest = PageRequest.of(0, 5, Sort.by("price")
.descending()
.and(Sort.by("name")));
Page<Product> result = productRepository.findAll(pageRequest);
assertThat(result.getContent(), hasSize(5));
assertThat(result.getContent()
.stream()
.map(Product::getId)
.collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001, 1005, 1002)));
}
@Test
public void whenRequestingFirstPageOfSizeTwoUsingCustomMethod_ThenReturnFirstPage() {
Pageable pageRequest = PageRequest.of(0, 2);
List<Product> result = productRepository.findAllByPrice(10, pageRequest);
assertThat(result, hasSize(2));
assertTrue(result.stream()
.map(Product::getId)
.allMatch(id -> Arrays.asList(1002, 1005)
.contains(id)));
}
}
@@ -1,4 +0,0 @@
# configuration for test containers testing
spring.datasource.url=${DB_URL}
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}
@@ -1,4 +0,0 @@
# configuration for Test Containers testing
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
@@ -1,2 +0,0 @@
create table PERSON (ID int8 not null, FIRST_NAME varchar(255), LAST_NAME varchar(255), primary key (ID))
create table person (id int8 not null, first_name varchar(255), last_name varchar(255), primary key (id))
@@ -1,15 +0,0 @@
### Relevant Articles:
- [Spring JPA @Embedded and @EmbeddedId](https://www.baeldung.com/spring-jpa-embedded-method-parameters)
- [Generate Database Schema with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-generate-db-schema)
- [Partial Data Update with Spring Data](https://www.baeldung.com/spring-data-partial-update)
### Eclipse Config
After importing the project into Eclipse, you may see the following error:
"No persistence xml file found in project"
This can be ignored:
- Project -> Properties -> Java Persistance -> JPA -> Error/Warnings -> Select Ignore on "No persistence xml file found in project"
Or:
- Eclipse -> Preferences - Validation - disable the "Build" execution of the JPA Validator
@@ -0,0 +1,23 @@
## Spring Data JPA - Annotations
This module contains articles about annotations used in Spring Data JPA
### Relevant articles
- [Spring Data Annotations](https://www.baeldung.com/spring-data-annotations)
- [DDD Aggregates and @DomainEvents](https://www.baeldung.com/spring-data-ddd)
- [JPA @Embedded And @Embeddable](https://www.baeldung.com/jpa-embedded-embeddable)
- [Spring Data JPA @Modifying Annotation](https://www.baeldung.com/spring-data-jpa-modifying-annotation)
- [Spring JPA @Embedded and @EmbeddedId](https://www.baeldung.com/spring-jpa-embedded-method-parameters)
- [Programmatic Transaction Management in Spring](https://www.baeldung.com/spring-programmatic-transaction-management)
- [JPA Entity Lifecycle Events](https://www.baeldung.com/jpa-entity-lifecycle-events)
### Eclipse Config
After importing the project into Eclipse, you may see the following error:
"No persistence xml file found in project"
This can be ignored:
- Project -> Properties -> Java Persistance -> JPA -> Error/Warnings -> Select Ignore on "No persistence xml file found in project"
Or:
- Eclipse -> Preferences - Validation - disable the "Build" execution of the JPA Validator
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-data-jpa-annotations</artifactId>
<name>spring-data-jpa-annotations</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-2</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- Test containers only dependencies -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.postgresql.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- Test containers only dependencies -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
</dependencies>
<properties>
<start-class>com.baeldung.boot.Application</start-class>
<testcontainers.postgresql.version>1.10.6</testcontainers.postgresql.version>
<postgresql.version>42.2.5</postgresql.version>
<guava.version>21.0</guava.version>
</properties>
</project>
@@ -1,14 +1,15 @@
## Spring Data JPA - CRUD
This module contains articles about CRUD operations in Spring Data JPA
### Relevant Articles:
- [Limiting Query Results with JPA and Spring Data JPA](https://www.baeldung.com/jpa-limit-query-results)
- [Sorting Query Results with Spring Data](https://www.baeldung.com/spring-data-sorting)
- [Spring Data JPA Derived Delete Methods](https://www.baeldung.com/spring-data-jpa-deleteby)
- [Spring Data JPA Delete and Relationships](https://www.baeldung.com/spring-data-jpa-delete)
- [INSERT Statement in JPA](https://www.baeldung.com/jpa-insert)
- [Pagination and Sorting using Spring Data JPA](https://www.baeldung.com/spring-data-jpa-pagination-sorting)
- [Spring Data JPA Query by Example](https://www.baeldung.com/spring-data-query-by-example)
- [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)
- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush)
- [Generate Database Schema with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-generate-db-schema)
### Eclipse Config
After importing the project into Eclipse, you may see the following error:
@@ -4,8 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-data-jpa-3</artifactId>
<name>spring-data-jpa-3</name>
<artifactId>spring-data-jpa-crud</artifactId>
<name>spring-data-jpa-crud</name>
<parent>
<groupId>com.baeldung</groupId>
@@ -0,0 +1,14 @@
spring.main.allow-bean-definition-overriding=true
spring.jpa.properties.hibernate.jdbc.batch_size=4
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.generate_statistics=true
# JPA-Schema-Generation
# Use below configuration to generate database schema create commands based on the entity models
# and export them into the create.sql file
#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=create.sql
#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-source=metadata
#spring.jpa.properties.hibernate.format_sql=true

Some files were not shown because too many files have changed in this diff Show More