// Path: src/main/java/com/clevergang/dbtests/repository/impl/mybatis/MyBatisDataRepositoryImpl.java
// @Repository
// public class MyBatisDataRepositoryImpl implements DataRepository {
// 
//     private final DataRepositoryMapper sql;
//     private final SqlSession batchOperations;
// 
//     @SuppressWarnings("SpringJavaAutowiringInspection")
//     @Autowired
//     public MyBatisDataRepositoryImpl(DataRepositoryMapper sql, @Qualifier("batch-operations") SqlSession batchOperations) {
//         this.sql = sql;
//         this.batchOperations = batchOperations;
//     }
// 
//     @Override
//     public Company findCompany(Integer pid) {
//         return sql.findCompany(pid);
//     }
// 
//     @Override
//     public Company findCompanyUsingSimpleStaticStatement(Integer pid) {
//         /*
//          * !!!!! NOTE THAT you can actually use parameters for SQL with statementType=STATEMENT, but you have to use ${pid} notation
//          * (notice $ instead of #) in the mapping xml!
//          */
//         return sql.findCompanyStatic(pid);
//     }
// 
//     @Override
//     public void removeProject(Integer pid) {
//         sql.removeProject(pid);
//     }
// 
//     @Override
//     public Department findDepartment(Integer pid) {
//         return sql.findDepartment(pid);
//     }
// 
//     @Override
//     public List<Department> findDepartmentsOfCompany(Company company) {
//         return sql.findDepartmentsOfCompany(company);
//     }
// 
//     @Override
//     public void deleteDepartments(List<Department> departmentsToDelete) {
//         sql.deleteDepartments(departmentsToDelete);
//     }
// 
//     @Override
//     public void updateDepartments(List<Department> departmentsToUpdate) {
//         DataRepositoryMapper batchSql = batchOperations.getMapper(DataRepositoryMapper.class);
//         departmentsToUpdate.forEach(batchSql::updateDepartment);
//         // we have to flush statements here - the records would be updated only at the end of the transaction otherwise
//         batchOperations.flushStatements();
//     }
// 
//     @Override
//     public void insertDepartments(List<Department> departmentsToInsert) {
//         DataRepositoryMapper batchSql = batchOperations.getMapper(DataRepositoryMapper.class);
//         departmentsToInsert.forEach(batchSql::insertDepartment);
//         // we have to flush statements here - the records would be inserted only at the end of the transaction otherwise
//         batchOperations.flushStatements();
//     }
// 
//     @Override
//     public Project findProject(Integer pid) {
//         return sql.findProject(pid);
//     }
// 
//     @Override
//     public Integer insertProject(Project project) {
//         sql.insertProject(project);
//         return project.getPid();
//     }
// 
//     @Override
//     public List<Integer> insertProjects(List<Project> projects) {
//         DataRepositoryMapper batchSql = batchOperations.getMapper(DataRepositoryMapper.class);
//         projects.forEach(batchSql::insertProject);
//         // we have to flush statements here - the records would be inserted only at the end of the transaction otherwise
//         batchOperations.flushStatements();
// 
//         // MyBatis can actually return the PIDs from batch operation
//         return projects.stream().map(Project::getPid).collect(Collectors.toList());
//     }
// 
//     @Override
//     public List<ProjectsWithCostsGreaterThanOutput> getProjectsWithCostsGreaterThan(int totalCostBoundary) {
//         return sql.getProjectsWithCostsGreaterThan(totalCostBoundary);
//     }
// 
//     @Override
//     public Employee findEmployee(Integer pid) {
//         return sql.findEmployee(pid);
//     }
// 
//     @Override
//     public List<Employee> employeesWithSalaryGreaterThan(Integer minSalary) {
//         return sql.employeesWithSalaryGreaterThan(minSalary);
//     }
// 
//     @Override
//     public void updateEmployee(Employee employeeToUpdate) {
//         sql.updateEmployee(employeeToUpdate);
//     }
// 
//     @Override
//     public RegisterEmployeeOutput callRegisterEmployee(String name, String surname, String email, BigDecimal salary, String departmentName, String companyName) {
//         return sql.callRegisterEmployee(name, surname, email, salary, departmentName, companyName);
//     }
// 
//     @Override
//     public Integer getProjectsCount() {
//         return sql.getProjectsCount();
//     }
// }


import com.clevergang.dbtests.repository.impl.mybatis.MyBatisDataRepositoryImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
package com.clevergang.dbtests;


/**
 * @author Bretislav Wajtr
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = DbTestsApplication.class)
@Transactional
@Rollback
public class MyBatisScenariosTest {

    @SuppressWarnings("SpringJavaAutowiringInspection")
    @Autowired
// Path: src/main/java/com/clevergang/dbtests/repository/impl/mybatis/MyBatisDataRepositoryImpl.java
// @Repository
// public class MyBatisDataRepositoryImpl implements DataRepository {
// 
//     private final DataRepositoryMapper sql;
//     private final SqlSession batchOperations;
// 
//     @SuppressWarnings("SpringJavaAutowiringInspection")
//     @Autowired
//     public MyBatisDataRepositoryImpl(DataRepositoryMapper sql, @Qualifier("batch-operations") SqlSession batchOperations) {
//         this.sql = sql;
//         this.batchOperations = batchOperations;
//     }
// 
//     @Override
//     public Company findCompany(Integer pid) {
//         return sql.findCompany(pid);
//     }
// 
//     @Override
//     public Company findCompanyUsingSimpleStaticStatement(Integer pid) {
//         /*
//          * !!!!! NOTE THAT you can actually use parameters for SQL with statementType=STATEMENT, but you have to use ${pid} notation
//          * (notice $ instead of #) in the mapping xml!
//          */
//         return sql.findCompanyStatic(pid);
//     }
// 
//     @Override
//     public void removeProject(Integer pid) {
//         sql.removeProject(pid);
//     }
// 
//     @Override
//     public Department findDepartment(Integer pid) {
//         return sql.findDepartment(pid);
//     }
// 
//     @Override
//     public List<Department> findDepartmentsOfCompany(Company company) {
//         return sql.findDepartmentsOfCompany(company);
//     }
// 
//     @Override
//     public void deleteDepartments(List<Department> departmentsToDelete) {
//         sql.deleteDepartments(departmentsToDelete);
//     }
// 
//     @Override
//     public void updateDepartments(List<Department> departmentsToUpdate) {
//         DataRepositoryMapper batchSql = batchOperations.getMapper(DataRepositoryMapper.class);
//         departmentsToUpdate.forEach(batchSql::updateDepartment);
//         // we have to flush statements here - the records would be updated only at the end of the transaction otherwise
//         batchOperations.flushStatements();
//     }
// 
//     @Override
//     public void insertDepartments(List<Department> departmentsToInsert) {
//         DataRepositoryMapper batchSql = batchOperations.getMapper(DataRepositoryMapper.class);
//         departmentsToInsert.forEach(batchSql::insertDepartment);
//         // we have to flush statements here - the records would be inserted only at the end of the transaction otherwise
//         batchOperations.flushStatements();
//     }
// 
//     @Override
//     public Project findProject(Integer pid) {
//         return sql.findProject(pid);
//     }
// 
//     @Override
//     public Integer insertProject(Project project) {
//         sql.insertProject(project);
//         return project.getPid();
//     }
// 
//     @Override
//     public List<Integer> insertProjects(List<Project> projects) {
//         DataRepositoryMapper batchSql = batchOperations.getMapper(DataRepositoryMapper.class);
//         projects.forEach(batchSql::insertProject);
//         // we have to flush statements here - the records would be inserted only at the end of the transaction otherwise
//         batchOperations.flushStatements();
// 
//         // MyBatis can actually return the PIDs from batch operation
//         return projects.stream().map(Project::getPid).collect(Collectors.toList());
//     }
// 
//     @Override
//     public List<ProjectsWithCostsGreaterThanOutput> getProjectsWithCostsGreaterThan(int totalCostBoundary) {
//         return sql.getProjectsWithCostsGreaterThan(totalCostBoundary);
//     }
// 
//     @Override
//     public Employee findEmployee(Integer pid) {
//         return sql.findEmployee(pid);
//     }
// 
//     @Override
//     public List<Employee> employeesWithSalaryGreaterThan(Integer minSalary) {
//         return sql.employeesWithSalaryGreaterThan(minSalary);
//     }
// 
//     @Override
//     public void updateEmployee(Employee employeeToUpdate) {
//         sql.updateEmployee(employeeToUpdate);
//     }
// 
//     @Override
//     public RegisterEmployeeOutput callRegisterEmployee(String name, String surname, String email, BigDecimal salary, String departmentName, String companyName) {
//         return sql.callRegisterEmployee(name, surname, email, salary, departmentName, companyName);
//     }
// 
//     @Override
//     public Integer getProjectsCount() {
//         return sql.getProjectsCount();
//     }
// }


// Path: src/test/java/com/clevergang/dbtests/MyBatisScenariosTest.java
import com.clevergang.dbtests.repository.impl.mybatis.MyBatisDataRepositoryImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;

package com.clevergang.dbtests;


/**
 * @author Bretislav Wajtr
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = DbTestsApplication.class)
@Transactional
@Rollback
public class MyBatisScenariosTest {

    @SuppressWarnings("SpringJavaAutowiringInspection")
    @Autowired
    private MyBatisDataRepositoryImpl myBatisDataRepository;