How to restrict the Soft deleted values

Hi,

How to restrict the soft deleted values ?
If I soft delete the row from parent or child then I need to restrict to load the parent with child row(Soft deleted row) in the parent browser as well as in child

Hi Mallik,
What do you mean by “restrict to load”?

  1. If you want to soft delete the records on both sides of the association, use DeletePolicy.CASCADE:
public class Parent extends StandardEntity {

    @OnDelete(DeletePolicy.CASCADE)
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CHILD_ID")
    protected Child child;
    
    ...
}
  1. Another option is to use DeletePolicy.UNLINK in the owner side of the association: thus, the parent record will have null value for the child attribute, and you can simply restrict loading such records in the browser via the database query:
        <groupDatasource id="parentsDs" 
                         class="com.company.sample.entity.Parent" 
                         view="_local"> 
            <query> 
                <!&#91;CDATA&#91;select e from sample$Parent e where e.child is not null&#93;&#93;> 
            </query> 
        </groupDatasource>

Hi Olga,

I am using the below code

LoadContext<Data_Measure_Map> loadContext = LoadContext.create(Data_Measure_Map.class)
.setQuery(LoadContext.createQuery(“select e from keansacloud$Data_Measure_Map e where e.child is not null and e.plan_data_column=:column”)
.setParameter(“column”,val))
.setView(“data_Measure_Map-with-DMMEASURE-BUCKET”);

Here Data_Measure_Map is the parent and bucket is the child. Some of the rows are deleted from child table.
I need to restrict the soft deleted results while loading the results from parent and child with join

Unfortunately, I don’t understand what you are trying to implement.

Your code provides the same result as the datasource query above: it omits the parents with null children. Could you clarify where is the problem?