From a61c9cea43ad3b578d954f02a2de5f482033fbc9 Mon Sep 17 00:00:00 2001 From: kyubeom Date: Sat, 17 Aug 2024 12:16:53 +0900 Subject: [PATCH] =?UTF-8?q?#2=20jpa=20Entity=20nullable=20=EC=A0=95?= =?UTF-8?q?=EC=9D=98=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/out/persistence/entity/MealJpaEntity.kt | 6 +++--- .../entity/{Restaurant.kt => RestaurantJpaEntity.kt} | 10 +++++----- .../entity/{University.kt => UniversityJpaEntity.kt} | 9 ++++----- 3 files changed, 12 insertions(+), 13 deletions(-) rename core/src/main/kotlin/com/core/adapter/out/persistence/entity/{Restaurant.kt => RestaurantJpaEntity.kt} (67%) rename core/src/main/kotlin/com/core/adapter/out/persistence/entity/{University.kt => UniversityJpaEntity.kt} (68%) diff --git a/core/src/main/kotlin/com/core/adapter/out/persistence/entity/MealJpaEntity.kt b/core/src/main/kotlin/com/core/adapter/out/persistence/entity/MealJpaEntity.kt index b128842..6c26bcd 100644 --- a/core/src/main/kotlin/com/core/adapter/out/persistence/entity/MealJpaEntity.kt +++ b/core/src/main/kotlin/com/core/adapter/out/persistence/entity/MealJpaEntity.kt @@ -19,11 +19,11 @@ class MealJpaEntity { @Column(name = "type", length = 20) @Enumerated(EnumType.STRING) - var type: MealType? = null + var type: MealType? = MealType.LUNCH @Column(name = "status", length = 20) @Enumerated(EnumType.STRING) - var status: MealStatus? = null + var status: MealStatus? = MealStatus.OPEN @Comment("식사 가격") @Column(name = "price") @@ -31,7 +31,7 @@ class MealJpaEntity { @ManyToOne @JoinColumn(name = "meal_id") - var restaurant: Restaurant? = null + var restaurantJpaEntity: RestaurantJpaEntity? = null } \ No newline at end of file diff --git a/core/src/main/kotlin/com/core/adapter/out/persistence/entity/Restaurant.kt b/core/src/main/kotlin/com/core/adapter/out/persistence/entity/RestaurantJpaEntity.kt similarity index 67% rename from core/src/main/kotlin/com/core/adapter/out/persistence/entity/Restaurant.kt rename to core/src/main/kotlin/com/core/adapter/out/persistence/entity/RestaurantJpaEntity.kt index 2da6833..ae30b6b 100644 --- a/core/src/main/kotlin/com/core/adapter/out/persistence/entity/Restaurant.kt +++ b/core/src/main/kotlin/com/core/adapter/out/persistence/entity/RestaurantJpaEntity.kt @@ -6,21 +6,21 @@ import jakarta.persistence.* @Table(name = "restaurant", indexes = [ Index(name = "idx_name", columnList = "name"), ]) -class Restaurant { +class RestaurantJpaEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - val idx: Long? = null + val idx: Long = 0 @Column(name = "name") - val name: String? = null + val name: String = "DEFAULT" @Column(name = "address") - val address: String? = null + val address: String = "DEFAULT" @ManyToOne @JoinColumn(name = "category_id") - val university: University? = null + val universityJpaEntity: UniversityJpaEntity? = null } \ No newline at end of file diff --git a/core/src/main/kotlin/com/core/adapter/out/persistence/entity/University.kt b/core/src/main/kotlin/com/core/adapter/out/persistence/entity/UniversityJpaEntity.kt similarity index 68% rename from core/src/main/kotlin/com/core/adapter/out/persistence/entity/University.kt rename to core/src/main/kotlin/com/core/adapter/out/persistence/entity/UniversityJpaEntity.kt index 31ad840..e02d27e 100644 --- a/core/src/main/kotlin/com/core/adapter/out/persistence/entity/University.kt +++ b/core/src/main/kotlin/com/core/adapter/out/persistence/entity/UniversityJpaEntity.kt @@ -1,23 +1,22 @@ package com.core.adapter.out.persistence.entity import jakarta.persistence.* -import jakarta.persistence.criteria.CriteriaBuilder.In @Entity @Table(name = "university", indexes = [ Index(name = "idx_name", columnList = "name"), ]) -class University { +class UniversityJpaEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val idx: Long? = null @Column(name = "name") - val name: String? = null + val name: String = "DEFAULT" @Column(name = "campus_name") - val campusName: String? = null + val campusName: String = "DEFAULT" @Column(name = "is_deleted") - val isDeleted: Boolean? = null + val isDeleted: Boolean = true } \ No newline at end of file