com.cvent.dropwizard.mybatis.dataaccess.BaseDataAccess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropwizard-mybatis Show documentation
Show all versions of dropwizard-mybatis Show documentation
An open source bridge layer so that you can use mybatis with dropwizard + other useful utility methods often used within an enterprise.
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