From e11af10b9bc580278b8ddf2f8a6f80271e39ebe4 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 16 Dec 2019 08:51:01 +0100 Subject: [PATCH 1/2] BAEL-3385: Move article related code to its own package --- .../h2db/notnull/NotNullVsNullableApplication.java | 12 ++++++++++++ .../{springboot => notnull}/daos/ItemRepository.java | 4 ++-- .../h2db/{springboot => notnull}/models/Item.java | 2 +- .../{ => h2db/notnull}/ItemIntegrationTest.java | 9 ++++----- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/NotNullVsNullableApplication.java rename persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/{springboot => notnull}/daos/ItemRepository.java (64%) rename persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/{springboot => notnull}/models/Item.java (87%) rename persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/{ => h2db/notnull}/ItemIntegrationTest.java (75%) diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/NotNullVsNullableApplication.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/NotNullVsNullableApplication.java new file mode 100644 index 0000000000..5e8d69e3a1 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/NotNullVsNullableApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.h2db.notnull; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class NotNullVsNullableApplication { + + public static void main(String... args) { + SpringApplication.run(NotNullVsNullableApplication.class, args); + } +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/ItemRepository.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/daos/ItemRepository.java similarity index 64% rename from persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/ItemRepository.java rename to persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/daos/ItemRepository.java index 3007f56208..c1efc96d71 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/daos/ItemRepository.java +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/daos/ItemRepository.java @@ -1,6 +1,6 @@ -package com.baeldung.h2db.springboot.daos; +package com.baeldung.h2db.notnull.daos; -import com.baeldung.h2db.springboot.models.Item; +import com.baeldung.h2db.notnull.models.Item; import org.springframework.data.repository.CrudRepository; import java.math.BigDecimal; diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Item.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/models/Item.java similarity index 87% rename from persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Item.java rename to persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/models/Item.java index a5c5b0d3cb..d2c4015b86 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/springboot/models/Item.java +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/notnull/models/Item.java @@ -1,4 +1,4 @@ -package com.baeldung.h2db.springboot.models; +package com.baeldung.h2db.notnull.models; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/ItemIntegrationTest.java b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/h2db/notnull/ItemIntegrationTest.java similarity index 75% rename from persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/ItemIntegrationTest.java rename to persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/h2db/notnull/ItemIntegrationTest.java index 839dd87b7e..0e2e5e3319 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/ItemIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/h2db/notnull/ItemIntegrationTest.java @@ -1,8 +1,7 @@ -package com.baeldung; +package com.baeldung.h2db.notnull; -import com.baeldung.h2db.springboot.SpringBootH2Application; -import com.baeldung.h2db.springboot.daos.ItemRepository; -import com.baeldung.h2db.springboot.models.Item; +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; @@ -14,7 +13,7 @@ import javax.validation.ConstraintViolationException; import static org.assertj.core.api.Assertions.assertThatThrownBy; @RunWith(SpringRunner.class) -@SpringBootTest(classes = SpringBootH2Application.class) +@SpringBootTest(classes = NotNullVsNullableApplication.class) public class ItemIntegrationTest { @Autowired From 2a88751ec6ea8be9ca408a951c5d98f197e26c85 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 16 Dec 2019 08:53:28 +0100 Subject: [PATCH 2/2] BAEL-3385: Update README.md --- persistence-modules/spring-boot-persistence-h2/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/spring-boot-persistence-h2/README.md b/persistence-modules/spring-boot-persistence-h2/README.md index 377b7c8939..a0f9c67a33 100644 --- a/persistence-modules/spring-boot-persistence-h2/README.md +++ b/persistence-modules/spring-boot-persistence-h2/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Access the Same In-Memory H2 Database in Multiple Spring Boot Applications](https://www.baeldung.com/spring-boot-access-h2-database-multiple-apps) -- [Spring Boot With H2 Database](https://www.baeldung.com/spring-boot-h2-database) \ No newline at end of file +- [Spring Boot With H2 Database](https://www.baeldung.com/spring-boot-h2-database) +- [Hibernate @NotNull vs @Column(nullable = false)](https://www.baeldung.com/hibernate-notnull-vs-nullable) \ No newline at end of file