Enable sleep filter globally with spring-boot & spring -data

I am trying to implement a multi-level discriminator implementation using Spring Boot and Spring Data.

I created an abstract class to represent an object with several tenants. Something like this:

@MappedSuperclass @FilterDefs({@FilterDef(name = "multi-tenant", parameters = {@ParamDef(name = "tenant", type = "string")})}) @Filter(name = "multi-tenant", condition = "tenant = :tenant") public abstract class MultiTenantEntity extends GenericEntity { @Transient private transient String savedTenant; @PostLoad private void onLoad() throws Exception { this.savedTenant = this.tenant; onEntityModification(); } @PrePersist private void onPersist() { if (getId() == null || getId().equals(0l)) { tenant = SecurityUtil.getCurrentTenant(); } } @PreUpdate @PreRemove private void onEntityModification() throws Exception { String currentTenant = SecurityUtil.getCurrentTenant(); if (!currentTenant.equals(tenant) || !savedTenant.equals(tenant)) { throw new Exception(); } } @NotNull private String tenant; public String getTenant() { return tenant; } } 

How to enable global sleep filter with multiple tenants globally?

+8
java spring-boot spring-data spring-data-jpa hibernate
source share

No one has answered this question yet.

See similar questions:

7
DISCRIMINATOR based on multi-user work with Spring JPA + Hibernate data
2
Session access using Spring JPA and Hibernate to enable filters

or similar:

866
How to solve "Running plugins not covered by the lifecycle configuration" for Spring Data Maven Builds
708
How to configure port for Spring Boot application
565
What is the difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?
278
How to register SQL statements in spring boot?
7
How to enable sleep filter for sessionFactory.getCurrentSession ()?
7
DISCRIMINATOR based on multi-user work with Spring JPA + Hibernate data
3
Hibernate: Why is the FetchType.LAZY-annotated collection property eagerly loading?
one
Enabling global sleeping filters in jpa spring applications and spring boot
one
Hibernate Global Filter Does Not Apply to DML - Delete, Update Query
0
Multi-tenant configuration: StaleObjectStateException for transaction (hibernate + spring-data-jpa)

All Articles