use of net.robinfriedli.aiode.persist.qb.QueryBuilder in project aiode by robinfriedli.
the class AccessConfigurationPartitionInterceptor method intercept.
@Override
public void intercept(QueryBuilder<?, ?, ?, ?> queryBuilder) {
Optional<ExecutionContext> executionContext = ExecutionContext.Current.optional();
if (executionContext.isPresent() || (session != null && guildId != null)) {
Session session = executionContext.map(ExecutionContext::getSession).orElse(this.session);
String id = executionContext.map(ctx -> ctx.getGuild().getId()).orElse(guildId);
queryBuilder.where((cb, root, subQueryFactory) -> cb.equal(root.get("guildSpecification"), subQueryFactory.createUncorrelatedSubQuery(GuildSpecification.class, "pk").where((cb1, root1, subQueryFactory1) -> cb1.equal(root1.get("guildId"), id)).build(session)));
}
}
Aggregations