|
|
|
@ -15,16 +15,15 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.springframework.data.jdbc.mybatis; |
|
|
|
package org.springframework.data.jdbc.mybatis; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.ibatis.session.SqlSession; |
|
|
|
import org.apache.ibatis.session.SqlSession; |
|
|
|
import org.apache.ibatis.session.SqlSessionFactory; |
|
|
|
|
|
|
|
import org.mybatis.spring.SqlSessionTemplate; |
|
|
|
import org.mybatis.spring.SqlSessionTemplate; |
|
|
|
import org.springframework.data.jdbc.core.DataAccessStrategy; |
|
|
|
import org.springframework.data.jdbc.core.DataAccessStrategy; |
|
|
|
import org.springframework.data.jdbc.mapping.model.JdbcPersistentProperty; |
|
|
|
import org.springframework.data.jdbc.mapping.model.JdbcPersistentProperty; |
|
|
|
import org.springframework.data.mapping.PropertyPath; |
|
|
|
import org.springframework.data.mapping.PropertyPath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* {@link DataAccessStrategy} implementation based on MyBatis. Each method gets mapped to a statement. The name of the |
|
|
|
* {@link DataAccessStrategy} implementation based on MyBatis. Each method gets mapped to a statement. The name of the |
|
|
|
* statement gets constructed as follows: The namespace is based on the class of the entity plus the suffix "Mapper". |
|
|
|
* statement gets constructed as follows: The namespace is based on the class of the entity plus the suffix "Mapper". |
|
|
|
@ -42,14 +41,16 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy { |
|
|
|
|
|
|
|
|
|
|
|
private final SqlSession sqlSession; |
|
|
|
private final SqlSession sqlSession; |
|
|
|
|
|
|
|
|
|
|
|
public MyBatisDataAccessStrategy(SqlSessionFactory sqlSessionFactory) { |
|
|
|
/** |
|
|
|
|
|
|
|
* Constructs a {@link DataAccessStrategy} based on MyBatis. |
|
|
|
this(new SqlSessionTemplate(sqlSessionFactory)); |
|
|
|
* <p> |
|
|
|
} |
|
|
|
* Use a {@link SqlSessionTemplate} for {@link SqlSession} or a similar implementation tying the session to the |
|
|
|
|
|
|
|
* proper transaction. |
|
|
|
public MyBatisDataAccessStrategy(SqlSessionTemplate sqlSessionTemplate) { |
|
|
|
* |
|
|
|
|
|
|
|
* @param sqlSession Must be non {@literal null}. |
|
|
|
this.sqlSession = sqlSessionTemplate; |
|
|
|
*/ |
|
|
|
|
|
|
|
public MyBatisDataAccessStrategy(SqlSession sqlSession) { |
|
|
|
|
|
|
|
this.sqlSession = sqlSession; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|