Skip to content

Commit

Permalink
Merge pull request mybatis#434 from kazuki43zoo/improve-doc-for-flush…
Browse files Browse the repository at this point in the history
…Statements

Add explanations for SqlSession#flushStatements and @flush in documentation
  • Loading branch information
emacarron committed Jul 11, 2015
2 parents 2d7b4c2 + e556d1c commit bef570d
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/site/es/xdoc/java-api.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ public interface ResultHandler<T> {

<p>El parámetro ResultContext te da acceso al objeto resultado en sí mismo, un contador del número de objetos creados y un método booleano stop() que te permite indicar a MyBatis que pare la carga de datos.</p>

<h5>Batch update statement Flush Method</h5>
<p>There is method for flushing(executing) batch update statements that stored in a JDBC driver class at any timing. This method can be used when you use the <code>ExecutorType.BATCH</code> as <code>ExecutorType</code>.</p>
<source><![CDATA[List<BatchResult> flushStatements()]]></source>

<h5>Métodos de control de transacción</h5>
<p>El parámetro ResultContext te da acceso al objeto resultado en sí mismo, un contador del número de objetos creados y un método booleano stop() que te permite indicar a MyBatis que pare la carga de datos.</p>
<source>void commit()
Expand Down Expand Up @@ -463,6 +467,12 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
el valor de retorno será void y por tanto se requiere incluir esta anotación (o @ResultMap).
La anotación se ignora si el tipo devuelto por el méotdo no es void.</td>
</tr>
<tr>
<td><code>@Flush</code></td>
<td><code>Method</code></td>
<td>N/A</td>
<td>If this annotation is used, it can be called the <code>SqlSession#flushStatements()</code> via method defined at a Mapper interface.(MyBatis 3.3 or above)</td>
</tr>
</tbody>
</table>

Expand All @@ -476,6 +486,10 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
<source>@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="call identity()", keyProperty="nameId", before=<strong>false</strong>, resultType=<strong>int.class</strong>)
<strong>int</strong> insertTable2(Name name);</source>

<p>This example shows using the <code>@Flush</code> annotation to call the <code>SqlSession#flushStatements()</code>:</p>
<source><![CDATA[@Flush
List<BatchResult> flush();]]></source>
</subsection>

</section>
Expand Down
14 changes: 14 additions & 0 deletions src/site/ja/xdoc/java-api.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ public interface ResultHandler<T> {
<li>複雑な ResultMap では複数行のデータがひとつのオブジェクトにマッピングされることもあります。こうした ResultMap を ResultHandler と併用する際、association や collection のデータがマッピングされる前の状態のオブジェクトが渡される場合があります。</li>
</ul>

<h5>バッチ更新ステートメントをフラッシュするメソッド</h5>
<p>バッチ更新用に JDBC ドライバ内に蓄積されたステートメントを任意のタイミングでデータベースへフラッシュ(実行)するメソッドがあります。このメソッドは、 <code>ExecutorType</code> として <code>ExecutorType.BATCH</code> を使用している場合に使用することができます。</p>
<source><![CDATA[List<BatchResult> flushStatements()]]></source>

<h5>トランザクションを制御するメソッド</h5>
<p>トランザクションのスコープを制御するメソッドは4つあります。当然ですが、auto-commit を使用する場合や、外部のトランザクションマネージャーを使っている場合、これらのメソッドは効果がありません。しかし、Connection のインスタンスによって管理されている JDBC トランザクションマネージャーを利用している場合は便利なメソッドです。</p>
<source>void commit()
Expand Down Expand Up @@ -481,6 +485,12 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
<td>N/A</td>
<td>ResultHandler を使うメソッドでは戻り値の型が void となるので、このアノテーションを使って各行のデータをどのクラスにマップするかを指定します。XMLの ResultMap が存在する場合は @ResultMap アノテーションで指定することができます。XML の <code>&lt;select&gt;</code> 要素で resultType が指定されている場合はアノテーションによる指定は不要です。それ以外の場合、例えば @Select アノテーションが付加された引数に ResultHandler を含むメソッドの場合は戻り値の型は void である必要があるので、このアノテーション(あるいは @ResultMap)を使って型を指定する必要があります。メソッドの戻り値の型が void 以外の場合、このアノテーションは無視されます。</td>
</tr>
<tr>
<td><code>@Flush</code></td>
<td><code>Method</code></td>
<td>N/A</td>
<td>このアノテーションを使用すると、<code>SqlSession#flushStatements()</code>メソッドを Mapper インタフェースに定義したメソッド経由で呼び出すことができます。(MyBatis 3.3以上)</td>
</tr>
</tbody>
</table>

Expand All @@ -494,6 +504,10 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
<source>@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="call identity()", keyProperty="nameId", before=<strong>false</strong>, resultType=<strong>int.class</strong>)
<strong>int</strong> insertTable2(Name name);</source>

<p>次のコードは <code>@Flush</code> アノテーションを使って <code>SqlSession#flushStatements()</code>メソッドを呼び出す例です。</p>
<source><![CDATA[@Flush
List<BatchResult> flush();]]></source>
</subsection>

</section>
Expand Down
16 changes: 15 additions & 1 deletion src/site/ko/xdoc/java-api.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ public interface ResultHandler<T> {

<p>ResultContext 파라미터는 결과 객체에 접근할 수 있도록 해준다.</p>

<h5>Batch update statement Flush Method</h5>
<p>There is method for flushing(executing) batch update statements that stored in a JDBC driver class at any timing. This method can be used when you use the <code>ExecutorType.BATCH</code> as <code>ExecutorType</code>.</p>
<source><![CDATA[List<BatchResult> flushStatements()]]></source>

<h5>트랙잭션 제어 메서드</h5>
<p>트랜잭션을 제어하기 위해 4 개의 메서드가 있다. 물론 자동커밋을 선택하였거나 외부 트랜잭션 관리자를 사용하면 영향이
없다. 어쨌든, Connection 인스턴스에 의해 관리되고 JDBC 트랜잭션 관리자를 사용하면, 이 4 개의 메서드를 사용할 수
Expand Down Expand Up @@ -622,7 +626,13 @@ id 를 제공하기 위해 사용된다. XML 에 정의된 결과
예를들어, @Select 애노테이션이 선언되어 있다면 메소드는 결과 핸들러를 사용할 것이다.
결과 타입은 void여야만 하고 이 애노테이션(이나 @ResultMap)을 반드시 사용해야 한다.
이 애노테이션은 메소드 리턴타입이 void가 아니라면 무시한다. </td>
</tr>
</tr>
<tr>
<td><code>@Flush</code></td>
<td><code>Method</code></td>
<td>N/A</td>
<td>If this annotation is used, it can be called the <code>SqlSession#flushStatements()</code> via method defined at a Mapper interface.(MyBatis 3.3 or above)</td>
</tr>
</tbody>
</table>

Expand All @@ -636,6 +646,10 @@ id 를 제공하기 위해 사용된다. XML 에 정의된 결과
<source>@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="call identity()", keyProperty="nameId", before=<strong>false</strong>, resultType=<strong>int.class</strong>)
<strong>int</strong> insertTable2(Name name);</source>

<p>This example shows using the <code>@Flush</code> annotation to call the <code>SqlSession#flushStatements()</code>:</p>
<source><![CDATA[@Flush
List<BatchResult> flush();]]></source>
</subsection>

</section>
Expand Down
14 changes: 14 additions & 0 deletions src/site/xdoc/java-api.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ public interface ResultHandler<T> {
<li>When using advanced resultmaps MyBatis will probably require several rows to build an object. If a ResultHandler is used you may be given an object whose associations or collections are not yet filled.</li>
</ul>

<h5>Batch update statement Flush Method</h5>
<p>There is method for flushing(executing) batch update statements that stored in a JDBC driver class at any timing. This method can be used when you use the <code>ExecutorType.BATCH</code> as <code>ExecutorType</code>.</p>
<source><![CDATA[List<BatchResult> flushStatements()]]></source>

<h5>Transaction Control Methods</h5>
<p>There are four methods for controlling the scope of a transaction. Of course, these have no effect if you've chosen to use auto-commit or if you're using an external transaction manager. However, if you're using the JDBC transaction manager, managed by the Connection instance, then the four methods that will come in handy are:</p>
<source>void commit()
Expand Down Expand Up @@ -530,6 +534,12 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
will use a result handler, the return type must be void and this annotation (or @ResultMap)
is required. This annotation is ignored unless the method return type is void.</td>
</tr>
<tr>
<td><code>@Flush</code></td>
<td><code>Method</code></td>
<td>N/A</td>
<td>If this annotation is used, it can be called the <code>SqlSession#flushStatements()</code> via method defined at a Mapper interface.(MyBatis 3.3 or above)</td>
</tr>
</tbody>
</table>

Expand All @@ -543,6 +553,10 @@ try (SqlSession session = sqlSessionFactory.openSession()) {
<source>@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="call identity()", keyProperty="nameId", before=<strong>false</strong>, resultType=<strong>int.class</strong>)
<strong>int</strong> insertTable2(Name name);</source>

<p>This example shows using the <code>@Flush</code> annotation to call the <code>SqlSession#flushStatements()</code>:</p>
<source><![CDATA[@Flush
List<BatchResult> flush();]]></source>
</subsection>

</section>
Expand Down
15 changes: 15 additions & 0 deletions src/site/zh/xdoc/java-api.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ public interface ResultHandler<T> {
尔返回值的 stop()方法来停止 MyBatis 加载更多的结果。
</p>

<h5>Batch update statement Flush Method</h5>
<p>There is method for flushing(executing) batch update statements that stored in a JDBC driver class at any timing. This method can be used when you use the <code>ExecutorType.BATCH</code> as <code>ExecutorType</code>.</p>
<source><![CDATA[List<BatchResult> flushStatements()]]></source>


<h5>事务控制方法</h5>
<p>
控制事务范围有四个方法。
Expand Down Expand Up @@ -800,6 +805,12 @@ type,method。type 属性是类的完全限
will use a result handler, the return type must be void and this annotation (or @ResultMap)
is required. This annotation is ignored unless the method return type is void.</td>
</tr>
<tr>
<td><code>@Flush</code></td>
<td><code>Method</code></td>
<td>N/A</td>
<td>If this annotation is used, it can be called the <code>SqlSession#flushStatements()</code> via method defined at a Mapper interface.(MyBatis 3.3 or above)</td>
</tr>
</tbody>
</table>

Expand All @@ -813,6 +824,10 @@ type,method。type 属性是类的完全限
<source>@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="call identity()", keyProperty="nameId", before=<strong>false</strong>, resultType=<strong>int.class</strong>)
<strong>int</strong> insertTable2(Name name);</source>

<p>This example shows using the <code>@Flush</code> annotation to call the <code>SqlSession#flushStatements()</code>:</p>
<source><![CDATA[@Flush
List<BatchResult> flush();]]></source>
</subsection>

</section>
Expand Down

0 comments on commit bef570d

Please sign in to comment.