File tree Expand file tree Collapse file tree 3 files changed +23
-13
lines changed
main/java/org/mybatis/dynamic/sql
test/java/org/mybatis/dynamic/sql/mybatis3 Expand file tree Collapse file tree 3 files changed +23
-13
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright 2016-2017 the original author or authors.
2
+ * Copyright 2016-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -96,10 +96,23 @@ public String renderWithTableAlias(TableAliasCalculator tableAliasCalculator) {
96
96
.orElseGet (this ::name );
97
97
}
98
98
99
+ public <S > SqlColumn <S > withTypeHandler (String typeHandler ) {
100
+ SqlColumn <S > column = new SqlColumn <>(this );
101
+ column .typeHandler = Optional .of (typeHandler );
102
+ return column ;
103
+ }
104
+
99
105
private String applyTableAlias (String tableAlias ) {
100
106
return tableAlias + "." + name (); //$NON-NLS-1$
101
107
}
102
108
109
+ public static <T > SqlColumn <T > of (String name , SqlTable table , JDBCType jdbcType ) {
110
+ return SqlColumn .withName (name )
111
+ .withTable (table )
112
+ .withJdbcType (jdbcType )
113
+ .build ();
114
+ }
115
+
103
116
public static Builder withName (String name ) {
104
117
return new Builder ().withName (name );
105
118
}
Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright 2016-2017 the original author or authors.
2
+ * Copyright 2016-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -31,18 +31,11 @@ public String name() {
31
31
}
32
32
33
33
public <T > SqlColumn <T > column (String name , JDBCType jdbcType ) {
34
- return SqlColumn .withName (name )
35
- .withJdbcType (jdbcType )
36
- .withTable (this )
37
- .build ();
34
+ return SqlColumn .of (name , this , jdbcType );
38
35
}
39
36
40
37
public <T > SqlColumn <T > column (String name , JDBCType jdbcType , String typeHandler ) {
41
- return SqlColumn .withName (name )
42
- .withJdbcType (jdbcType )
43
- .withTypeHandler (typeHandler )
44
- .withTable (this )
45
- .build ();
38
+ return SqlColumn .of (name , this , jdbcType ).withTypeHandler (typeHandler );
46
39
}
47
40
48
41
public static SqlTable of (String name ) {
Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright 2016-2017 the original author or authors.
2
+ * Copyright 2016-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -130,7 +130,11 @@ public void testNoAliasWithoutIgnore() {
130
130
@ Test
131
131
public void testTypeHandler () {
132
132
SqlTable table = SqlTable .of ("foo" );
133
- SqlColumn <Date > column = table .column ("id" , JDBCType .DATE , "foo.Bar" );
133
+ SqlColumn <Date > column = SqlColumn .withName ("id" )
134
+ .withTable (table )
135
+ .withJdbcType (JDBCType .DATE )
136
+ .withTypeHandler ("foo.Bar" )
137
+ .build ();
134
138
IsEqualTo <Date > condition = IsEqualTo .of (() -> new Date ());
135
139
SqlCriterion <Date > criterion = SqlCriterion .withColumn (column )
136
140
.withCondition (condition )
You can’t perform that action at this time.
0 commit comments