Related entity processing, policy.deny not working

Hi,
I can’t see, what I am doing wrong.
I have two entities, l9003WkflowHdr and l9003WkflowDtl.
There should be an error message, when I try to remove a row in the …Hdr table when it has related rows in the …Dtl table.

Here are the part of the code in the …Hdr.java and …Dtl.java
HDR:

@NamePattern("%s|wkflowKey")
@DesignSupport("{'imported':true}")
@Table(name = "l_9003_wkflow_hdr")
@Entity(name = "cdlwkfl$L9003WkflowHdr")
public class L9003WkflowHdr extends BaseStringIdEntity {
    private static final long serialVersionUID = 5532332733376260913L;

    @OneToMany(mappedBy = "wkflowKey")
    protected List<L9003WkflowDtl> l9003WkflowDtls;

DTL:

@NamePattern("%s|wkflowDtlKey")
@DesignSupport("{'imported':true}")
@Table(name = "l_9003_wkflow_dtl")
@Entity(name = "cdlwkfl$L9003WkflowDtl")
public class L9003WkflowDtl extends BaseStringIdEntity {
    private static final long serialVersionUID = 812101951986642507L;

    @OnDeleteInverse(DeletePolicy.DENY)
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "wkflow_key")
    protected L9003WkflowHdr l9003WkflowHdr;

When I remove a …Hdr row, I do not get any error message when there are related rows in …Dtl.

Any help would be fine.

Thx Roland

Hi Roland,

DeletePolicy is handled only for entities supporting soft deletion. As I see from the source code, your entities do not implement SoftDelete interface. In this case, when you define On delete or On delete inverse in Studio, it generates appropriate DDL schema with on delete clauses for foreign keys, so it works on the database level. But your entities seem to be imported from an existing database, so you should create such foreign keys in the database yourself.

1 Like

Hi Konstantin,

thx for that!!!

Roland