From 49c573b5436fc40a20937bb275e4fb8ee319a760 Mon Sep 17 00:00:00 2001 From: Seungmin Choi Date: Fri, 10 Jan 2025 18:09:36 +0900 Subject: [PATCH 1/2] Fixed field name & set field length for PK length limit --- .../example/toyTeam6Airbnb/room/persistence/Address.kt | 8 ++++---- .../example/toyTeam6Airbnb/room/persistence/RoomEntity.kt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/Address.kt b/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/Address.kt index bb556cc..12f8e82 100644 --- a/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/Address.kt +++ b/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/Address.kt @@ -5,15 +5,15 @@ import jakarta.persistence.Embeddable @Embeddable data class Address( - @Column(name = "sido", nullable = false) + @Column(name = "sido", nullable = false, length = 50) val sido: String, - @Column(name = "sigungu", nullable = false) + @Column(name = "sigungu", nullable = false, length = 100) val sigungu: String, - @Column(name = "street", nullable = false) + @Column(name = "street", nullable = false, length = 100) val street: String, - @Column(name = "detail", nullable = false) + @Column(name = "detail", nullable = false, length = 100) val detail: String ) diff --git a/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/RoomEntity.kt b/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/RoomEntity.kt index 0c49547..9e9efea 100644 --- a/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/RoomEntity.kt +++ b/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/RoomEntity.kt @@ -24,7 +24,7 @@ import java.time.Instant name = "rooms", uniqueConstraints = [ UniqueConstraint( - columnNames = ["name", "type", "address_sido", "address_sigungu", "address_street", "address_detail"] + columnNames = ["name", "type", "sido", "sigungu", "street", "detail"] ) ] ) From 56e3a7832a7c8607e347817cee6d47ecf20e16a4 Mon Sep 17 00:00:00 2001 From: Seungmin Choi Date: Fri, 10 Jan 2025 19:49:59 +0900 Subject: [PATCH 2/2] fixed room entity unique constraint to just details --- .../example/toyTeam6Airbnb/room/persistence/Address.kt | 8 ++++---- .../example/toyTeam6Airbnb/room/persistence/RoomEntity.kt | 2 +- .../com/example/toyTeam6Airbnb/RoomConcurrencyTest.kt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/Address.kt b/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/Address.kt index 12f8e82..bb556cc 100644 --- a/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/Address.kt +++ b/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/Address.kt @@ -5,15 +5,15 @@ import jakarta.persistence.Embeddable @Embeddable data class Address( - @Column(name = "sido", nullable = false, length = 50) + @Column(name = "sido", nullable = false) val sido: String, - @Column(name = "sigungu", nullable = false, length = 100) + @Column(name = "sigungu", nullable = false) val sigungu: String, - @Column(name = "street", nullable = false, length = 100) + @Column(name = "street", nullable = false) val street: String, - @Column(name = "detail", nullable = false, length = 100) + @Column(name = "detail", nullable = false) val detail: String ) diff --git a/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/RoomEntity.kt b/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/RoomEntity.kt index 9e9efea..896183f 100644 --- a/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/RoomEntity.kt +++ b/src/main/kotlin/com/example/toyTeam6Airbnb/room/persistence/RoomEntity.kt @@ -24,7 +24,7 @@ import java.time.Instant name = "rooms", uniqueConstraints = [ UniqueConstraint( - columnNames = ["name", "type", "sido", "sigungu", "street", "detail"] + columnNames = ["detail"] ) ] ) diff --git a/src/test/kotlin/com/example/toyTeam6Airbnb/RoomConcurrencyTest.kt b/src/test/kotlin/com/example/toyTeam6Airbnb/RoomConcurrencyTest.kt index 31ce889..9b6fd78 100644 --- a/src/test/kotlin/com/example/toyTeam6Airbnb/RoomConcurrencyTest.kt +++ b/src/test/kotlin/com/example/toyTeam6Airbnb/RoomConcurrencyTest.kt @@ -166,6 +166,6 @@ class RoomConcurrencyTest { latch.await() val rooms = roomRepository.findAll() - assertEquals(2, rooms.size) + assertEquals(1, rooms.size) } }