Hibernate:执行@PreRemove,但记录没有删除

时间:2018-05-13 16:27:08

标签: java spring hibernate jpa

存在多对多关系的绑定实体。当我删除依赖实体时,我希望也删除该实体。调用preRemove方法,但hibernate不会构建删除请求。

我做错了什么?

请帮助,3天试图解决问题((

@Entity
@Data
@Table(name = "SOME_TABLE_NAME")
@IdClass(ExpertAndRequestId.class)
public class ExpertAndRequest implements Serializable {

    @Id
    private Long managerId;

    @Id
    private Long requestId;

    private String comment;

    @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(name = "managerId", updatable = false, insertable = false, referencedColumnName = "id")
    //@OnDelete(action = OnDeleteAction.CASCADE)
    private Manager manager;


    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "requestId", updatable = false, insertable = false, referencedColumnName = "id")
    private ParticipantRequest request;

    @PreRemove
    public void preRemove(){
        // THIS METHOD EXECUTED
    }

}

0 个答案:

没有答案