I have two tables with a structure like this.
1) Table Obj -

2) subobj table

There is an is_deleted column in my script, when I delete, I don’t want to delete records, instead I want to set is_deleted to true and update the necessary dependencies.
1) consider that the user deletes a row from the obj table that has the identifier 1. Now the rows of subobjects associated with obj_id 1 should set is_deleted to true.
2) subobj fk 'parent_subobj'. , , subobj 2, is_deleted 'parent_subobj' 2.
: ( JBOSS)
Obj: -
@Entity
@Table(name = "obj", schema = "public")
public class Obj implements java.io.Serializable
{
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id", unique = true, nullable = false)
private int id;
@Column(name = "obj_name", length = 100)
private String objName;
@Column(name = "is_deleted")
private Boolean isDeleted;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "obj")
private Set<Subobj> subobjs = new HashSet<Subobj>(0);
}
Subobj: -
@Entity
@Table(name = "subobj", schema = "public")
public class Subobj implements java.io.Serializable
{
@Id
@Column(name = "id", unique = true, nullable = false)
private int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "obj_id")
private Obj obj;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_subobj")
private Subobj subobj;
@Column(name = "subobj_name", length = 100)
private String subobjName;
@Column(name = "is_deleted")
private Boolean isDeleted;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "subobj")
private Set<Subobj> subobjs = new HashSet<Subobj>(0);
}
Hibernate . ,