com.kenshoo.jooq.DeleteQueryBuilder Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of persistence-layer Show documentation
                Show all versions of persistence-layer Show documentation
A Java persistence layer based on JOOQ for high performance and business flow support.
                
             The newest version!
        
        package com.kenshoo.jooq;
import com.google.common.collect.ImmutableList;
import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.impl.TableImpl;
import java.util.Collection;
/**
 * Provides a convenient (and MySQL-friendly) way of solving the use-case of deleting records by N identifiers.
 * The simplest case is deleting by a list of IDs in which case it could be expressed with a simple IN. However in
 * terms of performance (and logs) it's better to do a join with a temporary table populated with those IDs instead.
 * This class does it automatically.
 *
 * The returned object is a resource and it is crucial to place it inside try/finally block so it could be closed
 */
public class DeleteQueryBuilder {
    private final DSLContext dslContext;
    public DeleteQueryBuilder(DSLContext dslContext) {
        this.dslContext = dslContext;
    }
    public BuilderWith table(final TableImpl table) {
        return new BuilderWith() {
            @Override
            public  BuilderIn1 withCondition(final Field field) {
                return values -> new DeleteQueryExtension(table, ImmutableList.of(
                        new FieldAndValues<>(field, values)),
                        dslContext);
            }
        };
    }
    public interface BuilderWith {
         BuilderIn1 withCondition(Field field);
    }
    public interface BuilderIn1 {
        DeleteQueryExtension in(Collection values);
    }
}
            © 2015 - 2025 Weber Informatics LLC | Privacy Policy