File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/main/java/org/springframework/data/jdbc/mybatis Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 2020
2121import org .apache .ibatis .session .SqlSession ;
2222import org .apache .ibatis .session .SqlSessionFactory ;
23+ import org .mybatis .spring .SqlSessionTemplate ;
2324import org .springframework .data .jdbc .core .DataAccessStrategy ;
2425import org .springframework .data .jdbc .mapping .model .JdbcPersistentProperty ;
2526import org .springframework .data .mapping .PropertyPath ;
3334 * methods taking a {@link PropertyPath} the entityTyoe if the context is set to the class of the leaf type.
3435 *
3536 * @author Jens Schauder
37+ * @author Kazuki Shimizu
3638 */
3739public class MyBatisDataAccessStrategy implements DataAccessStrategy {
3840
3941 private static final String MAPPER_SUFFIX = "Mapper" ;
4042
41- private final SqlSessionFactory sqlSessionFactory ;
43+ private final SqlSession sqlSession ;
4244
4345 public MyBatisDataAccessStrategy (SqlSessionFactory sqlSessionFactory ) {
4446
45- this .sqlSessionFactory = sqlSessionFactory ;
47+ this (new SqlSessionTemplate (sqlSessionFactory ));
48+ }
49+
50+ public MyBatisDataAccessStrategy (SqlSessionTemplate sqlSessionTemplate ) {
51+
52+ this .sqlSession = sqlSessionTemplate ;
4653 }
4754
4855 @ Override
@@ -135,7 +142,7 @@ private String mapper(Class<?> domainType) {
135142 }
136143
137144 private SqlSession sqlSession () {
138- return sqlSessionFactory . openSession () ;
145+ return this . sqlSession ;
139146 }
140147
141148 private String toDashPath (PropertyPath propertyPath ) {
You can’t perform that action at this time.
0 commit comments