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 20
20
21
21
import org .apache .ibatis .session .SqlSession ;
22
22
import org .apache .ibatis .session .SqlSessionFactory ;
23
+ import org .mybatis .spring .SqlSessionTemplate ;
23
24
import org .springframework .data .jdbc .core .DataAccessStrategy ;
24
25
import org .springframework .data .jdbc .mapping .model .JdbcPersistentProperty ;
25
26
import org .springframework .data .mapping .PropertyPath ;
33
34
* methods taking a {@link PropertyPath} the entityTyoe if the context is set to the class of the leaf type.
34
35
*
35
36
* @author Jens Schauder
37
+ * @author Kazuki Shimizu
36
38
*/
37
39
public class MyBatisDataAccessStrategy implements DataAccessStrategy {
38
40
39
41
private static final String MAPPER_SUFFIX = "Mapper" ;
40
42
41
- private final SqlSessionFactory sqlSessionFactory ;
43
+ private final SqlSession sqlSession ;
42
44
43
45
public MyBatisDataAccessStrategy (SqlSessionFactory sqlSessionFactory ) {
44
46
45
- this .sqlSessionFactory = sqlSessionFactory ;
47
+ this (new SqlSessionTemplate (sqlSessionFactory ));
48
+ }
49
+
50
+ public MyBatisDataAccessStrategy (SqlSessionTemplate sqlSessionTemplate ) {
51
+
52
+ this .sqlSession = sqlSessionTemplate ;
46
53
}
47
54
48
55
@ Override
@@ -135,7 +142,7 @@ private String mapper(Class<?> domainType) {
135
142
}
136
143
137
144
private SqlSession sqlSession () {
138
- return sqlSessionFactory . openSession () ;
145
+ return this . sqlSession ;
139
146
}
140
147
141
148
private String toDashPath (PropertyPath propertyPath ) {
You can’t perform that action at this time.
0 commit comments