Rather than deleting a record, our client would like to mark a record as deleted. We are using JPA2/Hibernate. I'd like to do something like the following:
@Entity
@Table(name="TABLE")
@ActionOverride(action="delete", with="activeFlag = false")
public class Table {
@Column(name="ACTIVE_FLAG")
boolean activeFlag;
// ...
}
I have done this in the past but I can't seem to find the right syntax and annotation.
Take a look at the hibernate documentation, the annotation you are looking for is @SQLDelete
.
@Entity
@Table(name="TABLE")
@SQLDelete(sql = "UPDATE TABLE SET ACTIVE_FLAG = false WHERE id = ?")
public class Table {
@Column(name="ACTIVE_FLAG")
boolean activeFlag;
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With