JAVA-20165 Upgrade spring-boot hibernate specific modules to JDK 11 (#13952)
* JAVA-20165 Upgrade spring-boot hibernate specific modules to JDK 11 * JAVA-20165 Migrating spring-boot-persistence-mongodb * JAVA-20165 Migrating spring-boot-persistence-mongodb-2 * JAVA-20165 Migrating spring-boot-persistence-mongodb-3 * JAVA-20165 Adding latest version for jdbi in spring-boot-persistence-2 module --------- Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
parent
e7d1d56c47
commit
bb9e5b65b4
|
@ -58,14 +58,14 @@
|
|||
<!-- <module>redis</module> FAILED -->
|
||||
<!-- <module>sirix</module> --> <!-- We haven't upgraded to java 11. Fixing in BAEL-10841 -->
|
||||
<module>solr</module>
|
||||
<!-- <module>spring-boot-persistence-2</module> FAILED -->
|
||||
<module>spring-boot-persistence-2</module>
|
||||
<module>spring-boot-persistence-3</module>
|
||||
<module>spring-boot-mysql</module>
|
||||
<module>spring-boot-persistence</module>
|
||||
<module>spring-boot-persistence-h2</module>
|
||||
<!-- <module>spring-boot-persistence-mongodb</module>
|
||||
<module>spring-boot-persistence-mongodb</module>
|
||||
<module>spring-boot-persistence-mongodb-2</module>
|
||||
<module>spring-boot-persistence-mongodb-3</module> FAILED -->
|
||||
<module>spring-boot-persistence-mongodb-3</module>
|
||||
<module>spring-data-arangodb</module>
|
||||
<module>spring-data-cassandra</module>
|
||||
<module>spring-data-cassandra-test</module>
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit-bom</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
|
@ -33,7 +26,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jdbi</groupId>
|
||||
<artifactId>jdbi3-spring4</artifactId>
|
||||
<artifactId>jdbi3-spring5</artifactId>
|
||||
<version>${jdbi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -55,7 +48,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jdbi</groupId>
|
||||
<artifactId>jdbi3-spring4</artifactId>
|
||||
<artifactId>jdbi3-spring5</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jdbi</groupId>
|
||||
|
@ -103,6 +96,7 @@
|
|||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql-connector-java.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
|
@ -143,10 +137,14 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<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>21.1.0.0</oracle-database.version>
|
||||
<jdbi.version>3.38.0</jdbi.version>
|
||||
<spring.boot.dependencies>3.0.5</spring.boot.dependencies>
|
||||
<c3p0.version>0.9.5.5</c3p0.version>
|
||||
<oracle-database.version>21.9.0.0</oracle-database.version>
|
||||
<!--add note in the root pom.xml-->
|
||||
<org.slf4j.version>2.0.7</org.slf4j.version>
|
||||
<logback.version>1.4.6</logback.version>
|
||||
<mysql-connector-java.version>8.0.33</mysql-connector-java.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -31,11 +31,11 @@ public class JdbiConfiguration {
|
|||
|
||||
// Register all available plugins
|
||||
log.info("[I27] Installing plugins... ({} found)", jdbiPlugins.size());
|
||||
jdbiPlugins.forEach(plugin -> jdbi.installPlugin(plugin));
|
||||
jdbiPlugins.forEach(jdbi::installPlugin);
|
||||
|
||||
// Register all available rowMappers
|
||||
log.info("[I31] Installing rowMappers... ({} found)", rowMappers.size());
|
||||
rowMappers.forEach(mapper -> jdbi.registerRowMapper(mapper));
|
||||
rowMappers.forEach(jdbi::registerRowMapper);
|
||||
|
||||
return jdbi;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import lombok.Data;
|
|||
public class CarModel {
|
||||
private Long id;
|
||||
private String name;
|
||||
private Integer year;
|
||||
private Integer yearDate;
|
||||
private String sku;
|
||||
private Long makerId;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class CarModelMapper implements RowMapper<CarModel>{
|
|||
.id(rs.getLong("id"))
|
||||
.name(rs.getString("name"))
|
||||
.sku(rs.getString("sku"))
|
||||
.year(rs.getInt("year"))
|
||||
.yearDate(rs.getInt("year"))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.baeldung.db.indexing;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
|
||||
@Entity
|
||||
class Image {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.baeldung.spring.oracle.pooling.entity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Book {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.baeldung.springboothsqldb.application.entities;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "customers")
|
||||
|
|
|
@ -5,9 +5,9 @@ import lombok.Getter;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
@AllArgsConstructor
|
||||
|
|
|
@ -5,10 +5,10 @@ import lombok.Getter;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
@AllArgsConstructor
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.baeldung.tomcatconnectionpool.application.entities;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "customers")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
--
|
||||
-- Insert
|
||||
--
|
||||
insert into car_maker(id,name) values (:id,:name);
|
||||
insert into car_maker(name) values (:name);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
--
|
||||
-- Insert
|
||||
--
|
||||
insert into car_model(maker_fk,name,sku,year) values (
|
||||
insert into car_model(maker_fk,name,sku,yearDate) values (
|
||||
:makerId,
|
||||
:name,
|
||||
:sku,
|
||||
:year );
|
||||
:yearDate );
|
||||
|
|
|
@ -76,7 +76,7 @@ public class SpringBootJdbiApplicationIntegrationTest {
|
|||
@Test
|
||||
public void givenExistingCarMaker_whenFindById_thenReturnExistingCarMaker() {
|
||||
|
||||
CarMaker maker = carMakerDao.findById(1l);
|
||||
CarMaker maker = carMakerDao.findById(1L);
|
||||
assertThat(maker).isNotNull();
|
||||
assertThat(maker.getId()).isEqualTo(1);
|
||||
|
||||
|
@ -85,12 +85,12 @@ public class SpringBootJdbiApplicationIntegrationTest {
|
|||
@Test
|
||||
public void givenExistingCarMaker_whenBulkInsertFails_thenRollback() {
|
||||
|
||||
CarMaker maker = carMakerDao.findById(1l);
|
||||
CarMaker maker = carMakerDao.findById(1L);
|
||||
CarModel m1 = CarModel.builder()
|
||||
.makerId(maker.getId())
|
||||
.name("Model X1")
|
||||
.sku("1-M1")
|
||||
.year(2019)
|
||||
.yearDate(2019)
|
||||
.build();
|
||||
maker.getModels().add(m1);
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class SpringBootJdbiApplicationIntegrationTest {
|
|||
.makerId(maker.getId())
|
||||
.name("Model X1")
|
||||
.sku("1-M1")
|
||||
.year(2019)
|
||||
.yearDate(2019)
|
||||
.build();
|
||||
maker.getModels().add(m2);
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import static org.mockito.BDDMockito.given;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Paths;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -64,10 +66,13 @@ class FileSystemImageIntegrationTest {
|
|||
|
||||
private FileSystemResource baeldungJpegResource() {
|
||||
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
||||
String imagePath = classLoader.getResource("baeldung.jpeg")
|
||||
.getFile();
|
||||
|
||||
return new FileSystemResource(Paths.get(imagePath));
|
||||
try {
|
||||
final URL resource = classLoader.getResource("baeldung.jpeg");
|
||||
if (resource != null) {
|
||||
return new FileSystemResource(new File(resource.toURI()).getAbsolutePath());
|
||||
}
|
||||
} catch (URISyntaxException ignore) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Optional;
|
||||
|
@ -68,11 +70,15 @@ class ImageIntegrationTest {
|
|||
|
||||
private Image baeldungImage() throws IOException {
|
||||
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
||||
|
||||
Image mockImage = new Image();
|
||||
mockImage.setContent(Files.readAllBytes(Paths.get(classLoader.getResource("baeldung.jpeg")
|
||||
.getFile())));
|
||||
return mockImage;
|
||||
try {
|
||||
final URL resource = classLoader.getResource("baeldung.jpeg");
|
||||
if (resource != null) {
|
||||
Image mockImage = new Image();
|
||||
mockImage.setContent(Files.readAllBytes(Paths.get(resource.toURI())));
|
||||
return mockImage;
|
||||
}
|
||||
} catch (URISyntaxException ignore) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@ public class CustomerControllerIntegrationTest {
|
|||
|
||||
@Before
|
||||
public void setUpJsonMediaType() {
|
||||
MEDIA_TYPE_JSON = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
|
||||
|
||||
MEDIA_TYPE_JSON = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
|
||||
insert into car_maker(id,name) values (1,'Special Motors');
|
||||
insert into car_maker(id,name) values (2,'BWM');
|
||||
insert into car_maker(id,name) values (3,'Dolores');
|
||||
insert into car_maker(id,name) values (99,'Special Motors');
|
||||
insert into car_maker(id,name) values (100,'BWM');
|
||||
insert into car_maker(id,name) values (102,'Dolores');
|
||||
|
||||
insert into car_model(id,maker_fk,name,sku,year) values(1,1,'Muze','SM001',2018);
|
||||
insert into car_model(id,maker_fk,name,sku,year) values(2,1,'Empada','SM002',2008);
|
||||
insert into car_model(id,maker_fk,name,sku,yearDate) values(132,99,'Muze','SM001',2018);
|
||||
insert into car_model(id,maker_fk,name,sku,yearDate) values(145,99,'Empada','SM002',2008);
|
||||
|
||||
insert into car_model(id,maker_fk,name,sku,year) values(4,2,'BWM-100','BWM100',2008);
|
||||
insert into car_model(id,maker_fk,name,sku,year) values(5,2,'BWM-200','BWM200',2009);
|
||||
insert into car_model(id,maker_fk,name,sku,year) values(6,2,'BWM-300','BWM300',2008);
|
||||
insert into car_model(id,maker_fk,name,sku,yearDate) values(43,100,'BWM-100','BWM100',2008);
|
||||
insert into car_model(id,maker_fk,name,sku,yearDate) values(564,100,'BWM-200','BWM200',2009);
|
||||
insert into car_model(id,maker_fk,name,sku,yearDate) values(343,100,'BWM-300','BWM300',2008);
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ create table car_model(
|
|||
maker_fk int not null,
|
||||
name varchar(128) not null,
|
||||
sku varchar(128) not null,
|
||||
year int not null
|
||||
yearDate int not null
|
||||
);
|
||||
|
||||
create unique index ui_car_model_01 on car_model(maker_fk,sku);
|
||||
create unique index ui_car_model_02 on car_model(maker_fk,name,year);
|
||||
create unique index ui_car_model_02 on car_model(maker_fk,name,yearDate);
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-boot-persistence-mongodb-2</artifactId>
|
||||
<name>spring-boot-persistence-mongodb-2</name>
|
||||
<packaging>war</packaging>
|
||||
<description>This is simple boot application for Spring boot persistence mongodb test</description>
|
||||
|
||||
<parent>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-boot-persistence-mongodb-3</artifactId>
|
||||
<name>spring-boot-persistence-mongodb-3</name>
|
||||
<packaging>war</packaging>
|
||||
<description>This is simple boot application for Spring boot persistence mongodb</description>
|
||||
|
||||
<parent>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-boot-persistence-mongodb</artifactId>
|
||||
<name>spring-boot-persistence-mongodb</name>
|
||||
<packaging>war</packaging>
|
||||
<description>This is simple boot application for Spring boot persistence mongodb test</description>
|
||||
|
||||
<parent>
|
||||
|
|
Loading…
Reference in New Issue