generated from pricelees/issue-pr-template
[#41] 예약 스키마 재정의 #42
@ -1,11 +1,6 @@
|
|||||||
package roomescape.common.entity
|
package roomescape.common.entity
|
||||||
|
|
||||||
import jakarta.persistence.Column
|
import jakarta.persistence.*
|
||||||
import jakarta.persistence.EntityListeners
|
|
||||||
import jakarta.persistence.Id
|
|
||||||
import jakarta.persistence.MappedSuperclass
|
|
||||||
import jakarta.persistence.PostLoad
|
|
||||||
import jakarta.persistence.PrePersist
|
|
||||||
import org.springframework.data.annotation.CreatedBy
|
import org.springframework.data.annotation.CreatedBy
|
||||||
import org.springframework.data.annotation.CreatedDate
|
import org.springframework.data.annotation.CreatedDate
|
||||||
import org.springframework.data.annotation.LastModifiedBy
|
import org.springframework.data.annotation.LastModifiedBy
|
||||||
@ -13,17 +8,13 @@ import org.springframework.data.annotation.LastModifiedDate
|
|||||||
import org.springframework.data.domain.Persistable
|
import org.springframework.data.domain.Persistable
|
||||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
import kotlin.jvm.Transient
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
@EntityListeners(AuditingEntityListener::class)
|
@EntityListeners(AuditingEntityListener::class)
|
||||||
abstract class AuditingBaseEntity(
|
abstract class AuditingBaseEntity(
|
||||||
@Id
|
id: Long,
|
||||||
@Column(name = "id")
|
) : BaseEntityV2(id) {
|
||||||
private val _id: Long,
|
|
||||||
|
|
||||||
@Transient
|
|
||||||
private var isNewEntity: Boolean = true
|
|
||||||
) : Persistable<Long> {
|
|
||||||
@Column(updatable = false)
|
@Column(updatable = false)
|
||||||
@CreatedDate
|
@CreatedDate
|
||||||
lateinit var createdAt: LocalDateTime
|
lateinit var createdAt: LocalDateTime
|
||||||
@ -43,6 +34,17 @@ abstract class AuditingBaseEntity(
|
|||||||
@LastModifiedBy
|
@LastModifiedBy
|
||||||
var updatedBy: Long = 0L
|
var updatedBy: Long = 0L
|
||||||
protected set
|
protected set
|
||||||
|
}
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
abstract class BaseEntityV2(
|
||||||
|
@Id
|
||||||
|
@Column(name = "id")
|
||||||
|
private val _id: Long,
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private var isNewEntity: Boolean = true
|
||||||
|
) : Persistable<Long> {
|
||||||
|
|
||||||
@PostLoad
|
@PostLoad
|
||||||
@PrePersist
|
@PrePersist
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user