Merge branch 'eugenp:master' into master

This commit is contained in:
Mladen Savic
2021-10-01 12:34:37 +02:00
committed by GitHub
357 changed files with 7841 additions and 1406 deletions
+32 -32
View File
@@ -16,6 +16,38 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencyManagement>
<dependencies>
<!-- JBoss distributes a complete set of Java EE 7 APIs including a Bill of Materials (BOM).
A BOM specifies the versions of a "stack" (or a collection) of artifacts. We use this here so that we
always get the correct versions of artifacts. Here we use the jboss-javaee-7.0-with-tools stack (you
can read this as the JBoss stack of the Java EE 7 APIs, with some extras tools for your project, such
as Arquillian for testing) and the jboss-javaee-7.0-with-hibernate stack you can read this as the JBoss
stack of the Java EE 7 APIs, with extras from the Hibernate family of projects) -->
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-tools</artifactId>
<version>${jboss.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-hibernate</artifactId>
<version>${jboss.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.distribution</groupId>
<artifactId>distributions-bom</artifactId>
<version>${deltaspike.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- First declare the APIs we depend on and need for compilation. All of them are provided by
JBoss WildFly -->
@@ -245,38 +277,6 @@
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<!-- JBoss distributes a complete set of Java EE 7 APIs including a Bill of Materials (BOM).
A BOM specifies the versions of a "stack" (or a collection) of artifacts. We use this here so that we
always get the correct versions of artifacts. Here we use the jboss-javaee-7.0-with-tools stack (you
can read this as the JBoss stack of the Java EE 7 APIs, with some extras tools for your project, such
as Arquillian for testing) and the jboss-javaee-7.0-with-hibernate stack you can read this as the JBoss
stack of the Java EE 7 APIs, with extras from the Hibernate family of projects) -->
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-tools</artifactId>
<version>${jboss.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-hibernate</artifactId>
<version>${jboss.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.distribution</groupId>
<artifactId>distributions-bom</artifactId>
<version>${deltaspike.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<querydsl.version>3.7.4</querydsl.version>
<deltaspike.version>1.8.2</deltaspike.version>
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<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>hibernate-enterprise</artifactId>
<version>0.0.1-SNAPSHOT</version>
@@ -77,7 +77,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<version>${org.slf4j.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
@@ -174,12 +174,10 @@
<javassist.version>3.27.0-GA</javassist.version>
<jaxb.version>2.3.1</jaxb.version>
<log4jdbc.version>2.0.0</log4jdbc.version>
<logback.version>1.2.3</logback.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<maven.compiler.version>3.8.1</maven.compiler.version>
<maven.version>3.8.1</maven.version>
<mysql.version>8.0.19</mysql.version>
<slf4j.version>1.7.30</slf4j.version>
<spring-boot.version>2.1.3.RELEASE</spring-boot.version>
</properties>
+2
View File
@@ -13,3 +13,5 @@ This module contains articles about the Java Persistence API (JPA) in Java.
- [Returning an Auto-Generated Id with JPA](https://www.baeldung.com/jpa-get-auto-generated-id)
- [How to Return Multiple Entities In JPA Query](https://www.baeldung.com/jpa-return-multiple-entities)
- [Defining Unique Constraints in JPA](https://www.baeldung.com/jpa-unique-constraints)
- [How to Check Field Existence in MongoDB?](https://www.baeldung.com/mongodb-check-field-exists)
- [Connecting to a Specific Schema in JDBC](https://www.baeldung.com/jdbc-connect-to-schema)
+3 -3
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<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>java-mongodb</artifactId>
<version>1.0-SNAPSHOT</version>
+3 -3
View File
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<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>redis</artifactId>
<version>0.1-SNAPSHOT</version>
@@ -146,7 +146,7 @@
<jdbi.version>3.9.1</jdbi.version>
<spring.boot.dependencies>2.1.8.RELEASE</spring.boot.dependencies>
<c3p0.version>0.9.5.2</c3p0.version>
<oracle-database.version>19.6.0.0</oracle-database.version>
<oracle-database.version>21.1.0.0</oracle-database.version>
</properties>
</project>
@@ -20,7 +20,8 @@ public class OracleConfiguration {
dataSource.setUser("books");
dataSource.setPassword("books");
dataSource.setURL("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1");
dataSource.setFastConnectionFailoverEnabled(true);
// Only with clients prior to v21
// dataSource.setFastConnectionFailoverEnabled(true);
dataSource.setImplicitCachingEnabled(true);
// Only with clients prior to v11.2
// dataSource.setConnectionCachingEnabled(true);
@@ -1,32 +0,0 @@
package com.baeldung.spring.oracle.pooling.configuration;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import oracle.ucp.jdbc.PoolDataSource;
import oracle.ucp.jdbc.PoolDataSourceFactory;
@Configuration
@Profile("oracle-ucp")
public class OracleUCPConfiguration {
@Bean
public DataSource dataSource() throws SQLException {
PoolDataSource dataSource = PoolDataSourceFactory.getPoolDataSource();
dataSource.setUser("books");
dataSource.setPassword("books");
dataSource.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
dataSource.setURL("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1");
dataSource.setFastConnectionFailoverEnabled(true);
dataSource.setInitialPoolSize(5);
dataSource.setMinPoolSize(5);
dataSource.setMaxPoolSize(10);
return dataSource;
}
}
@@ -21,6 +21,15 @@ spring.datasource.hikari.poolName=HikariPoolBooks
spring.datasource.tomcat.maxActive=15
spring.datasource.tomcat.minIdle=5
# UCP settings
#Note: These properties require JDBC version 21.0.0.0
spring.datasource.ucp.connection-factory-class-name=oracle.jdbc.pool.OracleDataSource
spring.datasource.ucp.sql-for-validate-connection=select * from dual
spring.datasource.ucp.connection-pool-name=UcpPoolBooks
spring.datasource.ucp.initial-pool-size=5
spring.datasource.ucp.min-pool-size=5
spring.datasource.ucp.max-pool-size=10
# JPA settings
spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect
spring.jpa.hibernate.use-new-id-generator-mappings=false
@@ -9,11 +9,13 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {SpringOraclePoolingApplication.class})
@ActiveProfiles({"oracle-pooling-basic", "oracle-ucp"})
@ActiveProfiles({"oracle-pooling-basic"})
@TestPropertySource(properties = "spring.datasource.type=oracle.ucp.jdbc.UCPDataSource")
public class SpringOraclePoolingApplicationOracleUCPLiveTest {
@Autowired
@@ -21,7 +23,7 @@ public class SpringOraclePoolingApplicationOracleUCPLiveTest {
@Test
public void givenOracleUCPConfiguration_thenBuildsOraclePoolDataSource() {
assertTrue(dataSource instanceof oracle.ucp.jdbc.PoolDataSource);
assertTrue(dataSource instanceof oracle.ucp.jdbc.UCPDataSource);
}
}
@@ -6,3 +6,5 @@ jdbc.pass=sa
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create-drop
spring.jpa.defer-datasource-initialization=true
@@ -1,7 +1,7 @@
<?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">
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-arangodb</artifactId>
<name>spring-data-arangodb</name>
@@ -18,7 +18,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.arangodb</groupId>
<artifactId>arangodb-spring-data</artifactId>
@@ -28,6 +28,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
@@ -52,8 +56,7 @@
</dependencies>
<properties>
<spring-boot.version>2.2.6.RELEASE</spring-boot.version>
<cassandra-unit-spring.version>3.11.2.0</cassandra-unit-spring.version>
<cassandra-unit-spring.version>4.3.1.0</cassandra-unit-spring.version>
</properties>
</project>
@@ -1,2 +1,3 @@
spring.data.cassandra.keyspace-name=practice
spring.data.cassandra.port=9042
spring.data.cassandra.port=9042
spring.data.cassandra.local-datacenter=datacenter1
@@ -1,7 +1,7 @@
<?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">
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-cassandra-test</artifactId>
<name>spring-data-cassandra-test</name>
@@ -14,6 +14,50 @@
<relativePath>../../parent-boot-2</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
<version>${spring-boot-starter-data-cassandra.version}</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
<version>${java-driver-core.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>native-protocol</artifactId>
<version>${native-protocol.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>cassandra</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<spring-boot-starter-data-cassandra.version>2.5.3</spring-boot-starter-data-cassandra.version>
<lombok.version>1.18.18</lombok.version>
@@ -23,55 +67,4 @@
<native-protocol.version>1.5.0</native-protocol.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
<version>${spring-boot-starter-data-cassandra.version}</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
<version>${java-driver-core.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>native-protocol</artifactId>
<version>${native-protocol.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>cassandra</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -1,8 +1,7 @@
<?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">
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-crud</artifactId>
<name>spring-data-jpa-crud</name>
@@ -1,7 +1,6 @@
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
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
@@ -9,6 +9,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -20,6 +21,7 @@ import com.baeldung.boot.web.controllers.CustomerController;
@RunWith(SpringRunner.class)
@SpringBootTest(classes=Application.class)
@AutoConfigureMockMvc
@ActiveProfiles("stats")
public class BatchInsertIntegrationTest {
@Autowired
@@ -35,6 +37,6 @@ public class BatchInsertIntegrationTest {
public void whenInsertingCustomers_thenCustomersAreCreated() throws Exception {
this.mockMvc.perform(post("/customers"))
.andExpect(status().isOk());
}
}
}
@@ -3,4 +3,6 @@ spring.jpa.show-sql=false
spring.jpa.properties.hibernate.jdbc.batch_size=5
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.batch_versioned_data=true
spring.jpa.properties.hibernate.batch_versioned_data=true
spring.jpa.properties.hibernate.generate_statistics=true
@@ -0,0 +1,5 @@
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
@@ -3,20 +3,23 @@ package com.baeldung.boot.daos;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
import java.util.Optional;
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.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import com.baeldung.Application;
import com.baeldung.boot.domain.MerchandiseEntity;
@RunWith(SpringRunner.class)
@SpringBootTest(classes=Application.class)
@SpringBootTest(classes = Application.class)
public class InventoryRepositoryIntegrationTest {
private static final String ORIGINAL_TITLE = "Pair of Pants";
@@ -58,4 +61,28 @@ public class InventoryRepositoryIntegrationTest {
assertEquals(BigDecimal.TEN, result.getPrice());
assertEquals(UPDATED_BRAND, result.getBrand());
}
@Test
@Transactional
public void shouldUpdateExistingEntryInDBWithoutSave() {
MerchandiseEntity pants = new MerchandiseEntity(ORIGINAL_TITLE, BigDecimal.ONE);
pants = repository.save(pants);
Long originalId = pants.getId();
// Update using setters
pants.setTitle(UPDATED_TITLE);
pants.setPrice(BigDecimal.TEN);
pants.setBrand(UPDATED_BRAND);
Optional<MerchandiseEntity> resultOp = repository.findById(originalId);
assertTrue(resultOp.isPresent());
MerchandiseEntity result = resultOp.get();
assertEquals(originalId, result.getId());
assertEquals(UPDATED_TITLE, result.getTitle());
assertEquals(BigDecimal.TEN, result.getPrice());
assertEquals(UPDATED_BRAND, result.getBrand());
}
}
@@ -7,6 +7,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles
- [Spring Data Reactive Repositories with MongoDB](https://www.baeldung.com/spring-data-mongodb-reactive)
- [Spring Data MongoDB Tailable Cursors](https://www.baeldung.com/spring-data-mongodb-tailable-cursors)
- [A Quick Look at R2DBC with Spring Data](https://www.baeldung.com/spring-data-r2dbc)
- [Spring Data Reactive Repositories with Couchbase](https://www.baeldung.com/spring-data-reactive-couchbase)
- [Spring Data MongoDB Tailable Cursors](https://www.baeldung.com/spring-data-mongodb-tailable-cursors)
@@ -147,10 +147,7 @@
<h2.version>1.4.200</h2.version>
<couchbaseMock.version>1.5.23</couchbaseMock.version>
<reactor-core.version>3.3.1.RELEASE</reactor-core.version>
<!--
This spring-boot.version is set manually,
For upgrading this please refer http://team.baeldung.com/browse/JAVA-2802
-->
<!-- This spring-boot.version is set manually, For upgrading this please refer http://team.baeldung.com/browse/JAVA-2802 -->
<spring-boot.version>2.2.6.RELEASE</spring-boot.version>
</properties>