File tree 3 files changed +43
-0
lines changed
main/java/org/mybatis/guice
test/java/org/mybatis/guice
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import org .apache .ibatis .session .SqlSessionManager ;
19
19
20
+ import com .google .common .base .Objects ;
21
+
20
22
import javax .inject .Inject ;
21
23
import javax .inject .Provider ;
22
24
@@ -43,4 +45,17 @@ public T get() {
43
45
return this .sqlSessionManager .getMapper (mapperType );
44
46
}
45
47
48
+ @ Override
49
+ public int hashCode () {
50
+ return Objects .hashCode (this .mapperType );
51
+ }
52
+
53
+ @ Override
54
+ public boolean equals (Object obj ) {
55
+ if (obj == null ){
56
+ return false ;
57
+ }
58
+ MapperProvider other = (MapperProvider ) obj ;
59
+ return Objects .equal (this .mapperType , other .mapperType );
60
+ }
46
61
}
Original file line number Diff line number Diff line change 20
20
import org .apache .ibatis .type .TypeException ;
21
21
import org .apache .ibatis .type .TypeHandler ;
22
22
23
+ import com .google .common .base .Objects ;
23
24
import com .google .inject .Inject ;
24
25
import com .google .inject .Injector ;
25
26
import com .google .inject .TypeLiteral ;
@@ -70,4 +71,19 @@ public TH get() {
70
71
}
71
72
return instance ;
72
73
}
74
+
75
+ @ Override
76
+ public int hashCode () {
77
+ return Objects .hashCode (this .typeHandlerTypeLiteral , this .handledType );
78
+ }
79
+
80
+ @ Override
81
+ public boolean equals (Object obj ) {
82
+ if (obj == null ){
83
+ return false ;
84
+ }
85
+ TypeHandlerProvider other = (TypeHandlerProvider ) obj ;
86
+ return Objects .equal (this .typeHandlerTypeLiteral , other .typeHandlerTypeLiteral ) &&
87
+ Objects .equal (this .handledType , other .handledType );
88
+ }
73
89
}
Original file line number Diff line number Diff line change @@ -54,6 +54,18 @@ protected void initialize() {
54
54
defaultStatementTimeout (null );
55
55
}
56
56
57
+ });
58
+ modules .add (new MyBatisModule () {
59
+
60
+ @ Override
61
+ protected void initialize () {
62
+ addMapperClass (ContactMapper .class );
63
+ handleType (CustomType .class ).with (CustomLongTypeHandler .class );
64
+ handleType (Address .class ).with (AddressTypeHandler .class );
65
+ addTypeHandlerClass (ContactIdTypeHandler .class );
66
+ addTypeHandlerClass (ContactNameTypeHandler .class );
67
+ }
68
+
57
69
});
58
70
59
71
return modules ;
You can’t perform that action at this time.
0 commit comments