How to append conditional query dynamically in Hibernate Filter

1.1k Views Asked by At

I have hibernate filter on one entity.

@Entity
@Cacheable
@Table(name="table_check")
@NamedQueries({
    @NamedQuery(name = "table_check.check_condition1", query = "SELECT obj FROM table_check obj WHERE 1 = 1")
})
@XmlRootElement
@FilterDefs({ 
    @FilterDef(name="table_test_filter" ,
                defaultCondition="test_condition = :param1")
    })

@Filters({
    @Filter(name="table_test_filter")})

public class Table extends TableChecksEntity implements java.io.Serializable {
    private static final long serialVersionUID = 1L;

}

I need to generate one dynamic query through java code before enabling this filter.

This query string will contain One or more tables other than current entity (Basically it will be a join with current entity).

Is it possible to add this query string to the above hibernate filter (which will be created via hibernate annotations) ?

0

There are 0 best solutions below