現在Java,SpringBoot,Domaを使ってWebサイトを作っています。
customerテーブルをupdateする際、
CustomerのEntityクラスに継承していないにもかかわらず
BaseEntityListener.classのPreUpdateのメソッドの中に処理が入ってしまうのはなぜでしょうか?
Entityクラスは以下です。
Java
1@Entity 2@Table(name = "customer") 3@AttributeOverride(name = "id", column = @Column(name = "customer_id", 4 nullable = false, columnDefinition = "BIGINT UNSIGNED")) 5public class Customer { 6 7 // fields without id column ... 8 9 public Customer() { 10 } 11 12 // getter and setter ... 13 14}
以下のようにしないと呼び出せないと思っていたのにBaseEntityListener.classに入ってしまうので不思議です。
Java
1@Entity(lister = BaseEntityListener.class) 2public class Customer extends BaseEntity
ちなみにBaseEntityListenerクラスは以下です。
Java
1public class BaseEntityListener { 2 3 @PrePersist 4 public void prePersist(BaseEntity entity) { 5 entity.setCreateDate(new Date()); 6 entity.setModifyDate(new Date()); 7 } 8 9 @PreUpdate 10 public void preUpdate(BaseEntity entity) { 11 entity.setModifyDate(new Date()); 12 } 13 14}
なぜ参照していないのにBaseEntityListenerクラスに処理が入ってしまうのでしょうか?
よろしくお願いいたします。
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。