Skip to content

Commit 77eae66

Browse files
committed
translations
1 parent 9c839db commit 77eae66

File tree

9 files changed

+200
-5
lines changed

9 files changed

+200
-5
lines changed

src/site/es/xdoc/dynamic-sql.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ AND title like ‘someTitle’]]></source>
158158
<p><span class="label important">NOTA</span> Puedes pasar como objeto de parámetro un List o un Array a MyBatis. Cuando haces esto, MyBatis lo envuelve automáticamente en un Map usando su nombre como clave. Las instancias de lista usarán “list” como clave y las instancias array usarán “array”.</p>
159159
<p>Esto finaliza la discusión sobre la configuración XML y los ficheros de mapeo XML. En la sección siguiente hablaremos del API Java en detalle, de forma que puedas obtener el máximo rendimiento de los mapeos que has creado.</p>
160160
</subsection>
161+
<subsection name="bind">
162+
<p>El elemento <code>bind</code> te permite crear una variable a partir de una expresion OGNL y asociarla al contexto. Por ejemplo:</p>
163+
<source><![CDATA[
164+
<select id="selectBlogsLike" parameterType="Blog" resultType="Blog">
165+
<bind name="pattern" value="'%' + _parameter.getTitle() + '%'" />
166+
SELECT * FROM BLOG
167+
WHERE title LIKE #{pattern}
168+
</select>]]></source>
169+
</subsection>
161170
<subsection name="Soporte de multiples vendedores de base de datos">
162171
<p>Si se ha configurado un databaseIdProvider la variable "_databaseId" estará disponible en el código dinámico, de esta forma puedes constrir distintas sntencias dependiendo del fabricante de la base de datos. Mira el siguiente ejemplo:</p>
163172
<source><![CDATA[<insert id="insert" parameterType="org.myapp.domain.User">
@@ -173,6 +182,38 @@ AND title like ‘someTitle’]]></source>
173182
</insert>
174183
]]></source>
175184
</subsection>
185+
<subsection name="Lenguajes de scripting customizados para SQL dinámico">
186+
<p>Desde la versión 3.2 MyBatis soporta la adición de lenguajes de scripting de forma que puedes
187+
añadir un driver de lenguaje y usar dicho lenguaje para escribir tus sentencias SQL.
188+
</p>
189+
<p>Hay dos lenguajes predefinidos:</p>
190+
<ul>
191+
<li>xml</li>
192+
<li>raw</li>
193+
</ul>
194+
<p>El lenguaje <code>xml</code> es el lenguaje por defecto. Permite ejecutar todos los tags dinámicos que hemos visto en las secciones anteriores.</p>
195+
<p>El lenguaje <code>raw</code> es en realidad la ausencia de lenguaje. Con esta configuración MyBatis sólo realiza la sustitución de parámetros
196+
y pasa la sentencia al driver de base de datos. Como supondrás el lenguaje <code>raw</code> es más rápido que el <code>xml</code>.
197+
</p>
198+
<p>Puedes indicar el lenguaje que quieres usar en cada statement añadiendo el atributo <code>lang</code> de la siguiente forma:
199+
</p>
200+
<source><![CDATA[<select id="selectBlog" lang="raw">
201+
SELECT * FROM BLOG
202+
</select>]]></source>
203+
<p>O, en el caso de que uses mappers, usando la anotación <code>@Lang</code>:</p>
204+
<source><![CDATA[public interface Mapper {
205+
@Lang(RawLanguageDriver.class)
206+
@Select("SELECT * FROM BLOG")
207+
List<Blog> selectBlog();
208+
}]]></source>
209+
<p>También puedes implementar tu propio lenguaje implementado el siguiente interfaz:</p>
210+
<source><![CDATA[public interface LanguageDriver {
211+
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql);
212+
public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType);
213+
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType);
214+
}]]></source>
215+
<p></p>
216+
</subsection>
176217
</section>
177218
</body>
178219
</document>

src/site/es/xdoc/java-api.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ try {
252252
session.commit();
253253
} finally {
254254
session.close();
255+
}</source>
256+
<p>O, si usas jdk 1.7+ y MyBatis 3.2+, puedes utilizar la sentencia try-with-resources:</p>
257+
<source>
258+
try (SqlSession session = sqlSessionFactory.openSession()) {
259+
// following 3 lines pseudocode for "doing some work"
260+
session.insert(...);
261+
session.update(...);
262+
session.delete(...);
263+
session.commit();
255264
}</source>
256265
<p><span class="label important">NOTE</span> Al igual que con SqlSessionFactory, puedes obtener la instancia de Configuration que está usando al SqlSession llamando al método getConfiguration().</p>
257266
<source>Configuration getConfiguration()</source>

src/site/ja/xdoc/dynamic-sql.xml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ AND title like ‘someTitle’]]></source>
164164
<p><span class="label important">NOTE</span> List のインスタンスや Array を引数オブジェクトとして MyBatis に渡すこともできます。この場合、MyBatis は渡された引数を Map に格納しキーとして名前を設定します。List のインスタンスは "list" というキーで Map に格納され、Array の場合は "array" というキーで格納されます。</p>
165165
<p>XML 設定ファイルと XML Mapper ファイルについての説明はここまでになります。次の章では、Java API について詳しく見ていきます。</p>
166166
</subsection>
167+
<subsection name="bind">
168+
<p>The <code>bind</code> element lets you create a variable out of an OGNL expression and bind it to the context. For example:</p>
169+
<source><![CDATA[
170+
<select id="selectBlogsLike" parameterType="Blog" resultType="Blog">
171+
<bind name="pattern" value="'%' + _parameter.getTitle() + '%'" />
172+
SELECT * FROM BLOG
173+
WHERE title LIKE #{pattern}
174+
</select>]]></source>
175+
</subsection>
167176
<subsection name="複数データベースのサポート">
168177
<p>databaseIdProvider が設定されている場合、条件式で "_databaseId" 変数が利用可能となります。この変数を使うと、実行時のデータベースに応じてステートメントを使い分けることができます。oracle と db2 で異なる select 文を発行する例を次に挙げておきます。</p>
169178
<source><![CDATA[<insert id="insert" parameterType="org.myapp.domain.User">
@@ -179,10 +188,37 @@ AND title like ‘someTitle’]]></source>
179188
</insert>
180189
]]></source>
181190
</subsection>
182-
</section>
183-
<section name="ダイナミック SQL 記述言語">
191+
<subsection name="ダイナミック SQL 記述言語">
184192
<p>バージョン 3.2 以降、ダイナミック SQL の記述言語が Pluggable になりました。言語ドライバーを記述することで、任意の言語でダイナミック SQL を記述することができます。</p>
185193
<p>機能の詳細については今後記述を追加する予定です。</p>
186-
</section>
194+
<p>There are two built-in languages:</p>
195+
<ul>
196+
<li>xml</li>
197+
<li>raw</li>
198+
</ul>
199+
<p>The <code>xml</code> language is the default one. It is able to execute all the dynamic tags we saw in the previous sections.</p>
200+
<p>The <code>raw</code> language is in fact the absence of language. When using this setting MyBatis just performs the
201+
parameter substitution and passes the statement to the database driver. As you may guess, the <code>raw</code> language
202+
is faster than the <code>xml</code> language.
203+
</p>
204+
<p>You can specify the language you want to use in an statement adding the <code>lang</code> attribute as follows:
205+
</p>
206+
<source><![CDATA[<select id="selectBlog" lang="raw">
207+
SELECT * FROM BLOG
208+
</select>]]></source>
209+
<p>Or, in the case you are using mappers, using the <code>@Lang</code> annotation:</p>
210+
<source><![CDATA[public interface Mapper {
211+
@Lang(RawLanguageDriver.class)
212+
@Select("SELECT * FROM BLOG")
213+
List<Blog> selectBlog();
214+
}]]></source>
215+
<p>You can also implement your own language driver by implementing the following interface:</p>
216+
<source><![CDATA[public interface LanguageDriver {
217+
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql);
218+
public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType);
219+
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType);
220+
}]]></source>
221+
</subsection>
222+
</section>
187223
</body>
188224
</document>

src/site/ja/xdoc/java-api.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,15 @@ try {
253253
session.commit();
254254
} finally {
255255
session.close();
256+
}</source>
257+
<p>Or, If you are using jdk 1.7+ and MyBatis 3.2+, you can use the try-with-resources statement:</p>
258+
<source>
259+
try (SqlSession session = sqlSessionFactory.openSession()) {
260+
// following 3 lines pseudocode for "doing some work"
261+
session.insert(...);
262+
session.update(...);
263+
session.delete(...);
264+
session.commit();
256265
}</source>
257266
<p><span class="label important">NOTE</span> SqlSessionFactory と同様、getConfiguration() メソッドを呼び出すことで使用中の Configuration のインスタンスを取得することができます。</p>
258267
<source>Configuration getConfiguration()</source>

src/site/ko/xdoc/dynamic-sql.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ AND title like ‘someTitle’]]></source>
178178
<p>XML 설정 파일과 XML 매핑 파일에 대해서는 이 정도에서 정리하고, 다음 섹션에서는 Java API 에 대해 좀더 상세하게
179179
살펴볼 것이다.</p>
180180
</subsection>
181+
<subsection name="bind">
182+
<p>The <code>bind</code> element lets you create a variable out of an OGNL expression and bind it to the context. For example:</p>
183+
<source><![CDATA[
184+
<select id="selectBlogsLike" parameterType="Blog" resultType="Blog">
185+
<bind name="pattern" value="'%' + _parameter.getTitle() + '%'" />
186+
SELECT * FROM BLOG
187+
WHERE title LIKE #{pattern}
188+
</select>]]></source>
189+
</subsection>
181190
<subsection name="Multi-db vendor support">
182191
<p>"_databaseId" 변수로 설정된 databaseIdProvider가 동적인 코드에도 사용가능하다면, 데이터베이스 제품별로 서로다른 구문을 사용할 수 있다. 다음의 예제를 보라:</p>
183192
<source><![CDATA[<insert id="insert" parameterType="org.myapp.domain.User">
@@ -193,6 +202,38 @@ AND title like ‘someTitle’]]></source>
193202
</insert>
194203
]]></source>
195204
</subsection>
205+
<subsection name="Pluggable Scripting Languages For Dynamic SQL">
206+
<p>Starting from version 3.2 MyBatis supports pluggable scripting languages,
207+
so you can plug a language driver and use that language to write your dynamic
208+
SQL queries.</p>
209+
<p>There are two built-in languages:</p>
210+
<ul>
211+
<li>xml</li>
212+
<li>raw</li>
213+
</ul>
214+
<p>The <code>xml</code> language is the default one. It is able to execute all the dynamic tags we saw in the previous sections.</p>
215+
<p>The <code>raw</code> language is in fact the absence of language. When using this setting MyBatis just performs the
216+
parameter substitution and passes the statement to the database driver. As you may guess, the <code>raw</code> language
217+
is faster than the <code>xml</code> language.
218+
</p>
219+
<p>You can specify the language you want to use in an statement adding the <code>lang</code> attribute as follows:
220+
</p>
221+
<source><![CDATA[<select id="selectBlog" lang="raw">
222+
SELECT * FROM BLOG
223+
</select>]]></source>
224+
<p>Or, in the case you are using mappers, using the <code>@Lang</code> annotation:</p>
225+
<source><![CDATA[public interface Mapper {
226+
@Lang(RawLanguageDriver.class)
227+
@Select("SELECT * FROM BLOG")
228+
List<Blog> selectBlog();
229+
}]]></source>
230+
<p>You can also implement your own language driver by implementing the following interface:</p>
231+
<source><![CDATA[public interface LanguageDriver {
232+
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql);
233+
public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType);
234+
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType);
235+
}]]></source>
236+
</subsection>
196237
</section>
197238
</body>
198239
</document>

src/site/ko/xdoc/java-api.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ try {
302302
session.commit();
303303
} finally {
304304
session.close();
305+
}</source>
306+
<p>Or, If you are using jdk 1.7+ and MyBatis 3.2+, you can use the try-with-resources statement:</p>
307+
<source>
308+
try (SqlSession session = sqlSessionFactory.openSession()) {
309+
// following 3 lines pseudocode for "doing some work"
310+
session.insert(...);
311+
session.update(...);
312+
session.delete(...);
313+
session.commit();
305314
}</source>
306315
<p><span class="label important">참고</span> SqlSessionFactory 처럼, SqlSession 이 getConfiguration() 메서드를 호출하여 Configuration 인스턴스를
307316
얻을 수 있다.</p>

src/site/xdoc/dynamic-sql.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ AND title like ‘someTitle’]]></source>
183183
]]></source>
184184
</subsection>
185185
<subsection name="Pluggable Scripting Languages For Dynamic SQL">
186-
<p>Starting from version 3.2 mybatis supports pluggable scripting languages,
186+
<p>Starting from version 3.2 MyBatis supports pluggable scripting languages,
187187
so you can plug a language driver and use that language to write your dynamic
188188
SQL queries.</p>
189189
<p>There are two built-in languages:</p>
@@ -193,7 +193,7 @@ AND title like ‘someTitle’]]></source>
193193
</ul>
194194
<p>The <code>xml</code> language is the default one. It is able to execute all the dynamic tags we saw in the previous sections.</p>
195195
<p>The <code>raw</code> language is in fact the absence of language. When using this setting MyBatis just performs the
196-
parameter substitution and passes it to the database driver. As you may guess, the <code>raw</code> language
196+
parameter substitution and passes the statement to the database driver. As you may guess, the <code>raw</code> language
197197
is faster than the <code>xml</code> language.
198198
</p>
199199
<p>You can specify the language you want to use in an statement adding the <code>lang</code> attribute as follows:

src/site/zh/xdoc/dynamic-sql.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@ foreach 元素是非常强大的,它允许你指定一个集合,声明集合项
239239
Java API,所以你可以得到你已经创建的最有效的映射。
240240
</p>
241241
</subsection>
242+
<subsection name="bind">
243+
<p>The <code>bind</code> element lets you create a variable out of an OGNL expression and bind it to the context. For example:</p>
244+
<source><![CDATA[
245+
<select id="selectBlogsLike" parameterType="Blog" resultType="Blog">
246+
<bind name="pattern" value="'%' + _parameter.getTitle() + '%'" />
247+
SELECT * FROM BLOG
248+
WHERE title LIKE #{pattern}
249+
</select>]]></source>
250+
</subsection>
242251
<subsection name="Multi-db vendor support">
243252
<p>If a databaseIdProvider was configured a "_databaseId" variable is available for dynamic code, so you can build different statements depending on database vendor. Have a look at the following example:</p>
244253
<source><![CDATA[<insert id="insert" parameterType="org.myapp.domain.User">
@@ -254,6 +263,38 @@ Java API,所以你可以得到你已经创建的最有效的映射。
254263
</insert>
255264
]]></source>
256265
</subsection>
266+
<subsection name="Pluggable Scripting Languages For Dynamic SQL">
267+
<p>Starting from version 3.2 MyBatis supports pluggable scripting languages,
268+
so you can plug a language driver and use that language to write your dynamic
269+
SQL queries.</p>
270+
<p>There are two built-in languages:</p>
271+
<ul>
272+
<li>xml</li>
273+
<li>raw</li>
274+
</ul>
275+
<p>The <code>xml</code> language is the default one. It is able to execute all the dynamic tags we saw in the previous sections.</p>
276+
<p>The <code>raw</code> language is in fact the absence of language. When using this setting MyBatis just performs the
277+
parameter substitution and passes the statement to the database driver. As you may guess, the <code>raw</code> language
278+
is faster than the <code>xml</code> language.
279+
</p>
280+
<p>You can specify the language you want to use in an statement adding the <code>lang</code> attribute as follows:
281+
</p>
282+
<source><![CDATA[<select id="selectBlog" lang="raw">
283+
SELECT * FROM BLOG
284+
</select>]]></source>
285+
<p>Or, in the case you are using mappers, using the <code>@Lang</code> annotation:</p>
286+
<source><![CDATA[public interface Mapper {
287+
@Lang(RawLanguageDriver.class)
288+
@Select("SELECT * FROM BLOG")
289+
List<Blog> selectBlog();
290+
}]]></source>
291+
<p>You can also implement your own language driver by implementing the following interface:</p>
292+
<source><![CDATA[public interface LanguageDriver {
293+
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql);
294+
public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType);
295+
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType);
296+
}]]></source>
297+
</subsection>
257298
</section>
258299
</body>
259300
</document>

src/site/zh/xdoc/java-api.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,15 @@ try {
410410
session.commit();
411411
} finally {
412412
session.close();
413+
}</source>
414+
<p>Or, If you are using jdk 1.7+ and MyBatis 3.2+, you can use the try-with-resources statement:</p>
415+
<source>
416+
try (SqlSession session = sqlSessionFactory.openSession()) {
417+
// following 3 lines pseudocode for "doing some work"
418+
session.insert(...);
419+
session.update(...);
420+
session.delete(...);
421+
session.commit();
413422
}</source>
414423
<p><span class="label important">注意</span> 就像 SqlSessionFactory,你可以通过调用 getConfiguration()方法获得 SqlSession
415424
使用的 Configuration 实例

0 commit comments

Comments
 (0)