Skip to content
Uragami Taichi edited this page Feb 28, 2025 · 5 revisions

doma-spring-boot have annotation based event handling feature instead of Doma EventListener.

e.g. The following code handles the entity before an insert.

import java.time.LocalDate;

import org.seasar.doma.boot.event.annotation.HandlePreInsert;
import org.springframework.stereotype.Component;

@Component
public class MessageHandler {
    @HandlePreInsert
    public void preInsert(Message message) {
        message.createdAt = LocalDate.now();
    }
}

The available annotations are as follows. You can probably infer the callback timing from the annotation names.

  • HandlePostDelete
  • HandlePostInsert
  • HandlePostUpdate
  • HandlePreDelete
  • HandlePreInsert
  • HandlePreUpdate
Clone this wiki locally