Hibernate filter not working with update query

In my application I have to use one filter condition (columnABC=:inputValue) for all SELECT/INSERT/UPDATE/DELETE queries. Column ‘columnABC’ exist in all tables within application.

I have defined filter def in package-info file

        name = "columnFilter",
        parameters = @ParamDef(name = "columnABC", type = "int"),
        defaultCondition = "columnABC = :columnABC")
package com.example.entities;

import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.ParamDef;

Defined filter on entity

@Filter(name = "columnFilter")
@Table(name = "table1")
public class Entity1 implements Serializable {

    @Column(name = "columnABC")
    private Integer ColumnABC;

public class Repository1 {
    private EntityManager entityManager;

 public void setFilter(Integer columnABC) {
        Session session = entityManager.unwrap(Session.class);
        Filter filter = session.enableFilter("columnFilter");
        filter.setParameter("columnABC", columnABC);

Filter is attached to session and it is getting appended for all findAll methods.For findById method it was not working so I have applied @Query and filter has attached to it.When I am running save statements filter is not getting attached to the query. What other option I can use to attach filter to update query.

public class Service1{

    private Entity1Repository entity1Repository;



There is no way to make this work for update/delete statements. What column does columnABC represent? Is it a tenant identifier? Or a column that is used for table partitioning?

Tenant identifier approach done thru using AbstractRoutingDataSource implementation. In our application we have 2 level data partitioning…One is achieved thru AbstractRoutingDataSource. Second level data separation trying to achieve thru filter approach.

We have two level data separation.One level achieved thru Multitenancy AbstractRoutingDataSource implementation.Second level trying to achieve using @Filter approach which has table partitioning for all select/update/insert/delete operatons

If you want to use this for table partitioning, you should update to Hibernate 6.2 which introduced the @PartitionKey annotation for exactly this purpose. Also see [Closed] Allow marking partition columns · Discussion #5353 · hibernate/hibernate-orm · GitHub