From 79bb9a5b0a41c93c90395194a921e95bdaba9031 Mon Sep 17 00:00:00 2001 From: banjjoknim Date: Thu, 24 Feb 2022 22:33:35 +0900 Subject: [PATCH] =?UTF-8?q?chore=20:=20=EC=B6=94=EA=B0=80=20=EC=84=A4?= =?UTF-8?q?=EB=AA=85=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../playground/domain/event/AggregateRootEvent.kt | 8 ++++++++ .../com/banjjoknim/playground/domain/event/DomainEvent.kt | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/domain/event/AggregateRootEvent.kt b/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/domain/event/AggregateRootEvent.kt index acfdfa5..b063927 100644 --- a/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/domain/event/AggregateRootEvent.kt +++ b/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/domain/event/AggregateRootEvent.kt @@ -6,6 +6,14 @@ import javax.persistence.GeneratedValue import javax.persistence.GenerationType import javax.persistence.Id +/** + * ``` + * AbstractAggregateRoot 를 이용하면 쉽게 이벤트를 구현할 수 있다. + * + * 단, 명시적으로 AggregateRootRepository 에서 save()가 호출되어야 이벤트가 발행된다. + * ``` + * @see AbstractAggregateRoot + */ @Entity class AggregateRootUser( @Id diff --git a/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/domain/event/DomainEvent.kt b/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/domain/event/DomainEvent.kt index 2790bb6..39a2fb7 100644 --- a/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/domain/event/DomainEvent.kt +++ b/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/domain/event/DomainEvent.kt @@ -9,6 +9,18 @@ import org.hibernate.internal.SessionFactoryImpl import org.hibernate.persister.entity.EntityPersister import org.springframework.stereotype.Component +/** + * ``` + * org.hibernate.event.spi.EventType 을 살펴보면, 다양한 이벤트 발행시점(상태)을 볼 수 있다. + * + * 다양한 이벤트 발행시점(상태)과 이벤트를 이용해서 비즈니스 로직을 처리할 수 있다. + * + * 이벤트를 심도있게, 더 잘 활용하고 싶다면 Hibernate Session Event (Hibernate Event Session) 를 공부하도록 하자. + * + * Hibernate Session 의 이벤트 인터셉트를 이용해서 다양하게 활용할 수 있다. + * ``` + * @see EventType + */ @Component class DomainEvent { @@ -20,6 +32,9 @@ class DomainEvent { } } +/** + * + */ @Component class CustomEventListener : PostInsertEventListener { override fun requiresPostCommitHanding(persister: EntityPersister?): Boolean {