You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
via the <code>ProviderContext</code>(available since MyBatis 3.4.5 or later) as method argument.(In MyBatis 3.4 or later, it's allow multiple parameters)
481
481
Atributos: value, type y method.
482
482
El atributo value y type es el nombre completamente cualificado de una clase
483
-
(The <code>type</code> attribute is alias for <code>value</code>, you must be specify either one).
483
+
(The <code>type</code> attribute is alias for <code>value</code>, you must be specify either one.
484
+
But both attributes can be omit when specify the <code>defaultSqlProviderType</code> as global configuration).
484
485
El method es el nombre un método de dicha clase
485
486
(Since 3.5.1, you can omit <code>method</code> attribute, the MyBatis will resolve a target method via the
486
487
<code>ProviderMethodResolver</code> interface.
@@ -635,6 +636,29 @@ class UserSqlProvider implements ProviderMethodResolver {
635
636
}
636
637
}]]></source>
637
638
639
+
<p>This example shows usage that share an sql provider class to all mapper methods using global configuration(Available since 3.5.6):</p>
640
+
<source><![CDATA[
641
+
Configuration configuration = new Configuration();
642
+
configuration.setDefaultSqlProviderType(TemplateFilePathProvider.class); // Specify an sql provider class for sharing on all mapper methods
643
+
// ...]]></source>
644
+
<source><![CDATA[
645
+
// Can omit the type/value attribute on sql provider annotation
646
+
// If omit it, the MyBatis apply the class that specified on defaultSqlProviderType.
647
+
public interface UserMapper {
648
+
649
+
@SelectProvider // Same with @SelectProvider(TemplateFilePathProvider.class)
650
+
User findUser(int id);
651
+
652
+
@InsertProvider // Same with @InsertProvider(TemplateFilePathProvider.class)
653
+
void createUser(User user);
654
+
655
+
@UpdateProvider // Same with @UpdateProvider(TemplateFilePathProvider.class)
656
+
void updateUser(User user);
657
+
658
+
@DeleteProvider // Same with @DeleteProvider(TemplateFilePathProvider.class)
659
+
void deleteUser(int id);
660
+
}]]></source>
661
+
638
662
<p>This example shows usage the default implementation of <code>ProviderMethodResolver</code>(available since MyBatis 3.5.1 or later):</p>
Mapper 메서드의 인수인 "Mapper interface type" and "Database ID" 과 <code>ProviderContext</code>(Mybatis 3.4.5 부터) 를 이용한 "Mapper method" 로 전달 된 객체를 메서드 매개변수로 전달할 수 있다.(마이바티스 3.4이상에서는 복수 파라미터를 허용한다.)
607
607
사용가능한 속성들 : value, type, method.
608
-
value and type 속성은 클래스 (The <code>type</code> attribute is alias for <code>value</code>, you must be specify either one).
608
+
value and type 속성은 클래스 (The <code>type</code> attribute is alias for <code>value</code>, you must be specify either one.
609
+
But both attributes can be omit when specify the <code>defaultSqlProviderType</code> as global configuration).
609
610
method 속성은 메소드명이다
610
611
(Since 3.5.1, you can omit <code>method</code> attribute, the MyBatis will resolve a target method via the
611
612
<code>ProviderMethodResolver</code> interface.
@@ -749,6 +750,29 @@ class UserSqlBuilder {
749
750
}
750
751
}]]></source>
751
752
753
+
<p>This example shows usage that share an sql provider class to all mapper methods using global configuration(Available since 3.5.6):</p>
754
+
<source><![CDATA[
755
+
Configuration configuration = new Configuration();
756
+
configuration.setDefaultSqlProviderType(TemplateFilePathProvider.class); // Specify an sql provider class for sharing on all mapper methods
757
+
// ...]]></source>
758
+
<source><![CDATA[
759
+
// Can omit the type/value attribute on sql provider annotation
760
+
// If omit it, the MyBatis apply the class that specified on defaultSqlProviderType.
761
+
public interface UserMapper {
762
+
763
+
@SelectProvider // Same with @SelectProvider(TemplateFilePathProvider.class)
764
+
User findUser(int id);
765
+
766
+
@InsertProvider // Same with @InsertProvider(TemplateFilePathProvider.class)
767
+
void createUser(User user);
768
+
769
+
@UpdateProvider // Same with @UpdateProvider(TemplateFilePathProvider.class)
770
+
void updateUser(User user);
771
+
772
+
@DeleteProvider // Same with @DeleteProvider(TemplateFilePathProvider.class)
773
+
void deleteUser(int id);
774
+
}]]></source>
775
+
752
776
<p>This example shows usage the default implementation of <code>ProviderMethodResolver</code>(available since MyBatis 3.5.1 or later):</p>
0 commit comments