Skip to content

Instantly share code, notes, and snippets.

@sumanentc
Last active October 29, 2019 05:00
Show Gist options
  • Save sumanentc/cca9174900bfaacb68633891feae27ee to your computer and use it in GitHub Desktop.
Save sumanentc/cca9174900bfaacb68633891feae27ee to your computer and use it in GitHub Desktop.
@Aspect
@Component
public class CityServiceAspect {
@Before("execution(* com.example.service.discriminator.CityService.*(..))&& target(cityService) ")
public void aroundExecution(JoinPoint pjp, CityService cityService) throws Throwable {
org.hibernate.Filter filter = cityService.entityManager.unwrap(Session.class).enableFilter("tenantFilter");
filter.setParameter("tenantId", TenantContext.getCurrentTenant());
filter.validate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment