JAVA-220644 | Upgrade spring-boot-persistence-h2 to Spring Boot 3 (#14998)
This commit is contained in:
parent
835cb8e15c
commit
106067388d
|
@ -11,9 +11,9 @@
|
|||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<artifactId>parent-boot-3</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
<relativePath>../../parent-boot-3</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -44,12 +44,19 @@
|
|||
<artifactId>db-util</artifactId>
|
||||
<version>${db-util.version}</version>
|
||||
</dependency>
|
||||
<!-- fixes https://hibernate.atlassian.net/browse/HHH-16593-->
|
||||
<!-- and https://discourse.hibernate.org/t/bootstrap-failed-with-hibernate-6-3-0-final/8200 -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate.orm</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>6.3.1.Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<!-- The main class to start by executing java -jar -->
|
||||
<start-class>com.baeldung.h2db.demo.server.SpringBootApp</start-class>
|
||||
<db-util.version>1.0.4</db-util.version>
|
||||
<db-util.version>1.0.7</db-util.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -1,7 +1,7 @@
|
|||
package com.baeldung.h2.exceptions.models;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class User {
|
||||
|
|
|
@ -3,15 +3,15 @@ package com.baeldung.h2db.demo.client;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan("com.baeldung.h2db.demo.client")
|
||||
public class ClientSpringBootApp {
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.baeldung.h2db.demo.server;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import javax.annotation.PostConstruct;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.h2.tools.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package com.baeldung.h2db.lazy_load_no_trans.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
|
@ -22,5 +23,6 @@ public class Document {
|
|||
|
||||
private String title;
|
||||
|
||||
@Column(name="user_id")
|
||||
private Long userId;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ import org.hibernate.annotations.Fetch;
|
|||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package com.baeldung.h2db.notnull.models;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Entity
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.baeldung.h2db.springboot.models;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.Objects;
|
||||
|
||||
@Table(name = "countries")
|
||||
|
|
|
@ -4,9 +4,9 @@ insert into "user" values (103, 'user3', 'comment3');
|
|||
insert into "user" values (104, 'user4', 'comment4');
|
||||
insert into "user" values (105, 'user5', 'comment5');
|
||||
|
||||
insert into "document" values (1, 'doc1', 101);
|
||||
insert into "document" values (2, 'doc2', 101);
|
||||
insert into "document" values (3, 'doc3', 101);
|
||||
insert into "document" values (4, 'doc4', 101);
|
||||
insert into "document" values (5, 'doc5', 102);
|
||||
insert into "document" values (6, 'doc6', 102);
|
||||
insert into "document" ("id","title","user_id") values (1, 'doc1', 101);
|
||||
insert into "document" ("id","title","user_id") values (2, 'doc2', 101);
|
||||
insert into "document" ("id","title","user_id") values (3, 'doc3', 101);
|
||||
insert into "document" ("id","title","user_id") values (4, 'doc4', 101);
|
||||
insert into "document" ("id","title","user_id") values (5, 'doc5', 102);
|
||||
insert into "document" ("id","title","user_id") values (6, 'doc6', 102);
|
|
@ -2,16 +2,17 @@ package com.baeldung.h2db.notnull;
|
|||
|
||||
import com.baeldung.h2db.notnull.daos.ItemRepository;
|
||||
import com.baeldung.h2db.notnull.models.Item;
|
||||
|
||||
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 javax.validation.ConstraintViolationException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NotNullVsNullableApplication.class)
|
||||
public class ItemIntegrationTest {
|
||||
|
@ -21,8 +22,8 @@ public class ItemIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void shouldNotAllowToPersistNullItemsPrice() {
|
||||
assertThatThrownBy(() -> itemRepository.save(new Item()))
|
||||
.hasRootCauseInstanceOf(ConstraintViolationException.class)
|
||||
.hasStackTraceContaining("must not be null");
|
||||
assertThatThrownBy(() -> itemRepository.save(new Item())).hasRootCauseInstanceOf(ConstraintViolationException.class)
|
||||
.hasStackTraceContaining("propertyPath=price")
|
||||
.hasStackTraceContaining("null");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue