Skip to content

Commit

Permalink
feat: TrafficEntity의 SoftDeleteListener 구현, 적용합니다
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 authored and nove1080 committed May 10, 2024
1 parent a4bc5b8 commit d7f0838
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.walking.data.entity.support.listener;

import com.walking.data.entity.traffic.TrafficEntity;
import javax.persistence.PreRemove;

public class TrafficEntitySoftDeleteListener {

@PreRemove
private void preRemove(TrafficEntity entity) {
entity.delete();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.walking.data.entity.traffic;

import com.walking.data.entity.support.listener.TrafficEntitySoftDeleteListener;
import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
Expand All @@ -16,11 +18,13 @@
import org.locationtech.jts.geom.Point;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Entity
@EntityListeners({AuditingEntityListener.class, TrafficEntitySoftDeleteListener.class})
@Builder(toBuilder = true)
@Table(name = "traffic")
@SQLDelete(sql = "UPDATE traffic SET deleted=true where id=?")
Expand Down

0 comments on commit d7f0838

Please sign in to comment.