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

com.cvent.dropwizard.mybatis.dataaccess.BaseDataAccess Maven / Gradle / Ivy

Go to download

An open source bridge layer so that you can use mybatis with dropwizard + other useful utility methods often used within an enterprise.

There is a newer version: 4.0.4
Show newest version
package com.cvent.dropwizard.mybatis.dataaccess;

import org.apache.ibatis.session.SqlSessionFactory;

import java.util.function.Function;

/**
 * This is the base class needed for data access classes to operate
 * under the multi-environment set up.
 * @author Nikhil Bhagwat
 */
public class BaseDataAccess {
    private Function sqlSessionFactoryFunction;

    /**
     * contructor
     * @param sqlSessionFactoryFunction
     */
    public BaseDataAccess(Function sqlSessionFactoryFunction) {
        this.sqlSessionFactoryFunction = sqlSessionFactoryFunction;
    }

    /**
     * Gets the sql session factory by environment name
     * The behavior of .apply() will be defined by the SessionBuilderFactory class
     * @param environment
     * @return SqlSessionFactory
     */
    protected SqlSessionFactory getSessionFactory(String environment) {
        return sqlSessionFactoryFunction.apply(environment);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy