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

org.babyfish.jimmer.sql.Associations Maven / Gradle / Ivy

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

import org.babyfish.jimmer.lang.NewChain;
import org.babyfish.jimmer.sql.ast.Executable;
import org.babyfish.jimmer.sql.ast.mutation.AssociationSaveCommand;
import org.babyfish.jimmer.sql.ast.tuple.Tuple2;

import java.sql.Connection;
import java.util.Collection;

public interface Associations {

    @NewChain
    Associations forConnection(Connection con);

    @NewChain
    Associations reverse();

    @NewChain
    default Associations checkExistence() {
        return checkExistence(true);
    }

    @NewChain
    Associations checkExistence(boolean checkExistence);

    @NewChain
    default Associations deleteUnnecessary() {
        return deleteUnnecessary(true);
    }

    @NewChain
    Associations deleteUnnecessary(boolean deleteUnnecessary);

    default int save(Object sourceId, Object targetId) {
        return saveCommand(sourceId, targetId).execute();
    }

    default int saveAll(Collection sourceIds, Collection targetIds) {
        return saveAllCommand(sourceIds, targetIds).execute();
    }

    default int saveAll(Collection> idTuples) {
        return saveAllCommand(idTuples).execute();
    }

    /**
     * Will be deleted since 1.0, please use {@link #saveAll(Collection, Collection)}
     */
    default int batchSave(Collection sourceIds, Collection targetIds) {
        return batchSaveCommand(sourceIds, targetIds).execute();
    }

    /**
     * Will be deleted since 1.0, please use {@link #saveAll(Collection)}
     */
    default int batchSave(Collection> idTuples) {
        return batchSaveCommand(idTuples).execute();
    }
    
    AssociationSaveCommand saveCommand(Object sourceId, Object targetId);

    AssociationSaveCommand saveAllCommand(Collection sourceIds, Collection targetIds);

    AssociationSaveCommand saveAllCommand(Collection> idTuples);

    /**
     * Will be deleted since 1.0, please use {@link #saveAllCommand(Collection, Collection)}
     */
    default AssociationSaveCommand batchSaveCommand(Collection sourceIds, Collection targetIds) {
        return saveAllCommand(sourceIds, targetIds);
    }

    /**
     * Will be deleted since 1.0, please use {@link #saveAllCommand(Collection)}
     */
    default AssociationSaveCommand batchSaveCommand(Collection> idTuples) {
        return saveAllCommand(idTuples);
    }

    default int delete(Object sourceId, Object targetId) {
        return deleteCommand(sourceId, targetId).execute();
    }

    default int deleteAll(Collection sourceIds, Collection targetIds) {
        return deleteAllCommand(sourceIds, targetIds).execute();
    }

    default int deleteAll(Collection> idTuples) {
        return deleteAllCommand(idTuples).execute();
    }

    /**
     * Will be deleted since 1.0, please use {@link #deleteAll(Collection, Collection)}
     */
    default int batchDelete(Collection sourceIds, Collection targetIds) {
        return batchDeleteCommand(sourceIds, targetIds).execute();
    }

    /**
     * Will be deleted since 1.0, please use {@link #deleteAll(Collection)}
     */
    default int batchDelete(Collection> idTuples) {
        return batchDeleteCommand(idTuples).execute();
    }

    Executable deleteCommand(Object sourceId, Object targetId);

    Executable deleteAllCommand(Collection sourceIds, Collection targetIds);

    Executable deleteAllCommand(Collection> idTuples);

    /**
     * Will be deleted since 1.0, please use {@link #deleteAllCommand(Collection, Collection)}
     */
    default Executable batchDeleteCommand(Collection sourceIds, Collection targetIds) {
        return deleteAllCommand(sourceIds, targetIds);
    }

    /**
     * Will be deleted since 1.0, please use {@link #deleteAllCommand(Collection)}
     */
    default Executable batchDeleteCommand(Collection> idTuples) {
        return deleteAllCommand(idTuples);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy