All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.babyfish.jimmer.sql.ast.mutation.BatchEntitySaveCommand Maven / Gradle / Ivy

There is a newer version: 0.9.19
Show newest version
package org.babyfish.jimmer.sql.ast.mutation;

import org.babyfish.jimmer.lang.NewChain;
import org.babyfish.jimmer.meta.ImmutableProp;
import org.babyfish.jimmer.meta.TypedProp;
import org.babyfish.jimmer.sql.DissociateAction;
import org.babyfish.jimmer.sql.TargetTransferMode;
import org.babyfish.jimmer.sql.ast.Executable;
import org.babyfish.jimmer.sql.ast.table.Table;
import org.babyfish.jimmer.sql.runtime.ExceptionTranslator;

import java.util.Collection;

public interface BatchEntitySaveCommand
        extends Executable>,
        AbstractEntitySaveCommand {

    @NewChain
    @Override
    BatchEntitySaveCommand setMode(SaveMode mode);

    @NewChain
    @Override
    BatchEntitySaveCommand setAssociatedModeAll(AssociatedSaveMode mode);

    @NewChain
    @Override
    BatchEntitySaveCommand setAssociatedMode(ImmutableProp prop, AssociatedSaveMode mode);

    @NewChain
    @Override
    default BatchEntitySaveCommand setAssociatedMode(TypedProp.Association prop, AssociatedSaveMode mode) {
        return setAssociatedMode(prop.unwrap(), mode);
    }

    @NewChain
    @Override
    BatchEntitySaveCommand setKeyProps(ImmutableProp... props);

    @NewChain
    @Override
    default BatchEntitySaveCommand setKeyProps(TypedProp... props) {
        ImmutableProp[] unwrappedProps = new ImmutableProp[props.length];
        for (int i = 0; i < props.length; i++) {
            unwrappedProps[i] = props[i].unwrap();
        }
        return setKeyProps(unwrappedProps);
    }

    @NewChain
    @Override
    BatchEntitySaveCommand setAutoIdOnlyTargetCheckingAll();

    @NewChain
    @Override
    default BatchEntitySaveCommand setAutoIdOnlyTargetChecking(TypedProp.Association prop) {
        return setAutoIdOnlyTargetChecking(prop.unwrap());
    }

    @NewChain
    @Override
    default BatchEntitySaveCommand setAutoIdOnlyTargetChecking(TypedProp.Association prop, boolean checking) {
        return setAutoIdOnlyTargetChecking(prop.unwrap(), checking);
    }

    @NewChain
    @Override
    default BatchEntitySaveCommand setAutoIdOnlyTargetChecking(ImmutableProp prop) {
        return setAutoIdOnlyTargetChecking(prop, true);
    }

    @NewChain
    @Override
    BatchEntitySaveCommand setAutoIdOnlyTargetChecking(ImmutableProp prop, boolean checking);

    @NewChain
    @Override
    default BatchEntitySaveCommand setDissociateAction(
            TypedProp.Reference prop,
            DissociateAction dissociateAction
    ) {
        return setDissociateAction(prop.unwrap(), dissociateAction);
    }

    @NewChain
    @Override
    BatchEntitySaveCommand setDissociateAction(
            ImmutableProp prop,
            DissociateAction dissociateAction
    );

    @NewChain
    @Override
    default BatchEntitySaveCommand setTargetTransferMode(
            TypedProp.ReferenceList prop,
            TargetTransferMode mode
    ) {
        return setTargetTransferMode(prop.unwrap(), mode);
    }

    @NewChain
    @Override
    BatchEntitySaveCommand setTargetTransferMode(
            ImmutableProp prop,
            TargetTransferMode mode
    );

    @NewChain
    @Override
    BatchEntitySaveCommand setTargetTransferModeAll(TargetTransferMode mode);

    @NewChain
    @Override
    BatchEntitySaveCommand setLockMode(LockMode lockMode);

    /**
     * Example: 
{@code
     *  sqlClient
     *      .getEntities()
     *      .saveEntitiesCommand(
     *          Arrays.asList(process1, process2, process3)
     *      )
     *      .setOptimisticLock(ProcessTable.class, (table, vf) -> {
     *          return Predicate.and(
     *              table.version().eq(vf.newNumber(ProcessProps.VERSION)),
     *              table.status().eq(States.PENDING)
     *          );
     *      })
     *      .execute()
     * }
*/ @NewChain > BatchEntitySaveCommand setOptimisticLock( Class tableType, UserOptimisticLock block ); @NewChain @Override BatchEntitySaveCommand setDeleteMode(DeleteMode mode); @NewChain @Override BatchEntitySaveCommand addExceptionTranslator(ExceptionTranslator translator); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy