Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

错别字和拦截器注释 #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/org/apache/ibatis/binding/MapperMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public static class SqlCommand {
private final SqlCommandType type;

public SqlCommand(Configuration configuration, Class<?> mapperInterface, Method method) {
//接口全限定名+点+方法名称 如 com.jd.UserDao.findOne
String statementName = mapperInterface.getName() + "." + method.getName();
MappedStatement ms = null;
if (configuration.hasStatement(statementName)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/ibatis/builder/BaseBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
/**
* 构建器的基类,建造者模式
*
* 也有模板模式
*/
public abstract class BaseBuilder {
//需要配置,类型别名注册,类型处理器注册3个东西
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,16 @@ private void databaseIdProviderElement(XNode context) throws Exception {
}
}

/**在构建Configuration对象时添加了 type="JDBC" 对应的事务工厂
* public Configuration() {
* //注册更多的类型别名,至于为何不直接在TypeAliasRegistry里注册,还需进一步研究
* typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class);
* @param context
* @return
* @throws Exception
*/
//7.1事务管理器

//<transactionManager type="JDBC">
// <property name="..." value="..."/>
//</transactionManager>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/ibatis/executor/BaseExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
/**
* 执行器基类
*
* 模板模式
*/
public abstract class BaseExecutor implements Executor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
/**
* 语句处理器的基类
*
* 模板模式
*/
public abstract class BaseStatementHandler implements StatementHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
*/
/**
* 路由选择语句处理器,有点像代理模式
*
* 大方向是委托模式
* 细节是策略模式,根据不同类型,选择不同处理策略
*/
public class RoutingStatementHandler implements StatementHandler {

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/apache/ibatis/jdbc/SqlRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void setUseGeneratedKeySupport(boolean useGeneratedKeySupport) {
this.useGeneratedKeySupport = useGeneratedKeySupport;
}

/*
/**
* Executes a SELECT statement that returns one row.
*
* @param sql The SQL
Expand All @@ -72,7 +72,7 @@ public Map<String, Object> selectOne(String sql, Object... args) throws SQLExcep
return results.get(0);
}

/*
/**
* Executes a SELECT statement that returns multiple rows.
*
* @param sql The SQL
Expand All @@ -95,7 +95,7 @@ public List<Map<String, Object>> selectAll(String sql, Object... args) throws SQ
}
}

/*
/**
* Executes an INSERT statement.
*
* @param sql The SQL
Expand Down Expand Up @@ -141,7 +141,7 @@ public int insert(String sql, Object... args) throws SQLException {
}
}

/*
/**
* Executes an UPDATE statement.
*
* @param sql The SQL
Expand All @@ -163,7 +163,7 @@ public int update(String sql, Object... args) throws SQLException {
}
}

/*
/**
* Executes a DELETE statement.
*
* @param sql The SQL
Expand All @@ -175,7 +175,7 @@ public int delete(String sql, Object... args) throws SQLException {
return update(sql, args);
}

/*
/**
* Executes any string as a JDBC Statement.
* Good for DDL
*
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/apache/ibatis/mapping/MappedStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@
*/
/**
* 映射的语句
*
* 对应一个mapper中的insert update delete select 标签的完整内容
*/
public final class MappedStatement {

private String resource;
private Configuration configuration;
/**
* insert update delete select 标签中设置的 id
*/
private String id;
private Integer fetchSize;
private Integer timeout;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/apache/ibatis/session/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public class Configuration {
//对象工厂和对象包装器工厂
protected ObjectFactory objectFactory = new DefaultObjectFactory();
protected ObjectWrapperFactory objectWrapperFactory = new DefaultObjectWrapperFactory();
//映射注册机
//映射注册器
protected MapperRegistry mapperRegistry = new MapperRegistry(this);

//默认禁用延迟加载
Expand All @@ -142,6 +142,7 @@ public class Configuration {
*/
protected Class<?> configurationFactory;

//拦截器执行链,pagehelper插件就是通过自定义拦截器实现分页
protected final InterceptorChain interceptorChain = new InterceptorChain();
//类型处理器注册机
protected final TypeHandlerRegistry typeHandlerRegistry = new TypeHandlerRegistry();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/apache/ibatis/session/SqlSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public interface SqlSession extends Closeable {
* 这一点。
*
* 一般情况下公司都会编写自己的Mybatis 物理分页插件
* 可以使用第三方开源分页插件 比如 pagehelper 使用的是Mybatis的拦截器实现
* @param <E> the returned list element type
* @param statement Unique identifier matching the statement to use.
* @param parameter A parameter object to pass to the statement.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/ibatis/type/BaseTypeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
/**
* 类型处理器的基类
*
* 模板模式
*/
public abstract class BaseTypeHandler<T> extends TypeReference<T> implements TypeHandler<T> {

Expand Down