org.babyfish.jimmer.sql.ast.mutation.BatchEntitySaveCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
The 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;
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
BatchEntitySaveCommand setKeyOnlyAsReferenceAll();
@NewChain
@Override
default BatchEntitySaveCommand setKeyOnlyAsReference(TypedProp.Association, ?> prop) {
return setKeyOnlyAsReference(prop.unwrap(), true);
}
@NewChain
@Override
default BatchEntitySaveCommand setKeyOnlyAsReference(TypedProp.Association, ?> prop, boolean asReference) {
return setKeyOnlyAsReference(prop.unwrap(), asReference);
}
@NewChain
@Override
default BatchEntitySaveCommand setKeyOnlyAsReference(ImmutableProp prop) {
return setKeyOnlyAsReference(prop, true);
}
@NewChain
@Override
BatchEntitySaveCommand setKeyOnlyAsReference(ImmutableProp prop, boolean asReference);
@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);
@Override
default BatchEntitySaveCommand setInvestigateKeyBasedUpdate() {
return setInvestigateKeyBasedUpdate(true);
}
@Override
BatchEntitySaveCommand setInvestigateKeyBasedUpdate(boolean investigate);
@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
default > BatchEntitySaveCommand setOptimisticLock(
Class tableType,
UserOptimisticLock block
) {
return setOptimisticLock(tableType, UnloadedVersionBehavior.IGNORE, block);
}
/**
* Example: {@code
* sqlClient
* .getEntities()
* .saveEntitiesCommand(
* Arrays.asList(process1, process2, process3)
* )
* .setOptimisticLock(ProcessTable.class, UnloadedVersionBehavior.INCREASE, (table, vf) -> {
* return Predicate.and(
* table.version().eq(vf.newNumber(ProcessProps.VERSION)),
* table.status().eq(States.PENDING)
* );
* })
* .execute()
* }
*/
@NewChain
> BatchEntitySaveCommand setOptimisticLock(
Class tableType,
UnloadedVersionBehavior unloadedVersionBehavior,
UserOptimisticLock block
);
@NewChain
@Override
BatchEntitySaveCommand setDeleteMode(DeleteMode mode);
@NewChain
@Override
BatchEntitySaveCommand addExceptionTranslator(ExceptionTranslator> translator);
}