Skip to content

Commit

Permalink
merge: (#483) entity 첫 저장시 merge로 인한 select query 방지
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaisqls authored May 8, 2023
2 parents d80631b + bb5d51e commit daba4b5
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package team.aliens.dms.domain.studyroom.usecase

import java.util.UUID
import team.aliens.dms.common.annotation.UseCase
import team.aliens.dms.domain.studyroom.dto.CreateStudyRoomRequest
import team.aliens.dms.domain.studyroom.service.StudyRoomService
import team.aliens.dms.domain.user.service.UserService
import java.util.UUID

@UseCase
class CreateStudyRoomUseCase(
Expand All @@ -18,15 +18,15 @@ class CreateStudyRoomUseCase(

studyRoomService.checkStudyRoomExistsByFloorAndName(request.floor, request.name, user.schoolId)
val studyRoom = studyRoomService.saveStudyRoom(
request.toStudyRoom(user.id)
request.toStudyRoom(schoolId = user.schoolId)
)

studyRoomService.saveAllStudyRoomTimeSlots(
request.toStudyRoomTimeSlots(studyRoom.id)
request.toStudyRoomTimeSlots(studyRoomId = studyRoom.id)
)

studyRoomService.saveAllSeats(
request.toSeats(studyRoom.id)
request.toSeats(studyRoomId = studyRoom.id)
)

return studyRoom.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import javax.persistence.MappedSuperclass

@MappedSuperclass
abstract class BaseUUIDEntity(

id: UUID?
) {
@Id
@GeneratedValue(generator = "timeBasedUUID")
@GenericGenerator(name = "timeBasedUUID", strategy = "team.aliens.dms.persistence.TimeBasedUUIDGenerator")
@Column(columnDefinition = "BINARY(16)", nullable = false)
val id: UUID?

)
val id: UUID? = if (id == UUID(0, 0)) null else id
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import javax.persistence.Table
@Table(name = "tbl_notice")
class NoticeJpaEntity(

override val id: UUID?,
id: UUID?,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "manager_id", columnDefinition = "BINARY(16)", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import javax.persistence.Table
@Table(name = "tbl_phrase")
class PhraseJpaEntity(

override val id: UUID,
id: UUID?,

@Column(columnDefinition = "VARCHAR(30)", nullable = false)
val content: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import javax.persistence.UniqueConstraint
)
class PointFilterJpaEntity(

override val id: UUID?,
id: UUID?,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "school_id", columnDefinition = "BINARY(16)", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import javax.persistence.Table
@Table(name = "tbl_point_history")
class PointHistoryJpaEntity(

override val id: UUID?,
id: UUID?,

@Column(columnDefinition = "VARCHAR(30)", nullable = false)
val studentName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import javax.persistence.Table
@Table(name = "tbl_point_option")
class PointOptionJpaEntity(

override val id: UUID?,
id: UUID?,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "school_id", columnDefinition = "BINARY(16)", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PhraseMapper : GenericMapper<Phrase, PhraseJpaEntity> {
override fun toDomain(entity: PhraseJpaEntity?): Phrase? {
return entity?.let {
Phrase(
id = entity.id,
id = entity.id!!,
content = entity.content,
type = entity.type,
standard = entity.standard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import javax.persistence.Table
@Table(name = "tbl_remain_option")
class RemainOptionJpaEntity(

override val id: UUID?,
id: UUID?,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "school_id", columnDefinition = "BINARY(16)", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import javax.persistence.UniqueConstraint
)
class RoomJpaEntity(

override val id: UUID?,
id: UUID?,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "school_id", columnDefinition = "BINARY(16)", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import javax.persistence.UniqueConstraint
)
class SchoolJpaEntity(

override val id: UUID?,
id: UUID?,

@Column(columnDefinition = "VARCHAR(20)", nullable = false)
val name: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import javax.persistence.Table
@Where(clause = "deleted_at is null")
class StudentJpaEntity(

override val id: UUID?,
id: UUID?,

@OneToOne(fetch = FetchType.LAZY, cascade = [CascadeType.MERGE])
@JoinColumn(name = "user_id", columnDefinition = "BINARY(16)", nullable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import javax.persistence.UniqueConstraint
)
class SeatJpaEntity(

override val id: UUID?,
id: UUID?,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "study_room_id", columnDefinition = "BINARY(16)", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import javax.persistence.Table
@Table(name = "tbl_seat_type")
class SeatTypeJpaEntity(

override val id: UUID?,
id: UUID?,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "school_id", columnDefinition = "BINARY(16)", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import javax.persistence.UniqueConstraint
)
class StudyRoomJpaEntity(

override val id: UUID?,
id: UUID?,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "school_id", columnDefinition = "BINARY(16)", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import javax.persistence.Table
@Table(name = "tbl_time_slot")
class TimeSlotJpaEntity(

override val id: UUID?,
id: UUID?,

@Column(columnDefinition = "TIME", nullable = false)
val startTime: LocalTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import javax.persistence.UniqueConstraint
)
class TagJpaEntity(

override val id: UUID?,
id: UUID?,

@Column(columnDefinition = "VARCHAR(10)", nullable = false)
val name: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import javax.persistence.Table
@Where(clause = "deleted_at is null")
class UserJpaEntity(

override val id: UUID?,
id: UUID?,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "school_id", columnDefinition = "BINARY(16)", nullable = false)
Expand Down

0 comments on commit daba4b5

Please sign in to comment.