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

org.fluentjdbc.DbSaveBuilderContext Maven / Gradle / Ivy

There is a newer version: 0.5.3
Show newest version
package org.fluentjdbc;

import java.sql.SQLException;

import org.fluentjdbc.util.ExceptionUtil;

public class DbSaveBuilderContext {

    private DbTableContext tableContext;
    private DatabaseSaveBuilder saveBuilder;

    public DbSaveBuilderContext(DbTableContext tableContext, DatabaseSaveBuilder saveBuilder) {
        this.tableContext = tableContext;
        this.saveBuilder = saveBuilder;
    }

    public DbSaveBuilderContext uniqueKey(String fieldName, Object fieldValue) {
        saveBuilder.uniqueKey(fieldName, fieldValue);
        return this;
    }

    public DbSaveBuilderContext setField(String fieldName, Object fieldValue) {
        saveBuilder.setField(fieldName, fieldValue);
        return this;
    }

    public DatabaseSaveResult execute() {
        try {
            return saveBuilder.execute(tableContext.getConnection());
        } catch (SQLException e) {
            throw ExceptionUtil.softenCheckedException(e);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy