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 11/**
2- * Copyright 2016-2017 the original author or authors.
2+ * Copyright 2016-2018 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -96,10 +96,23 @@ public String renderWithTableAlias(TableAliasCalculator tableAliasCalculator) {
9696 .orElseGet (this ::name );
9797 }
9898
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+
99105 private String applyTableAlias (String tableAlias ) {
100106 return tableAlias + "." + name (); //$NON-NLS-1$
101107 }
102108
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+
103116 public static Builder withName (String name ) {
104117 return new Builder ().withName (name );
105118 }
Original file line number Diff line number Diff line change 11/**
2- * Copyright 2016-2017 the original author or authors.
2+ * Copyright 2016-2018 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -31,18 +31,11 @@ public String name() {
3131 }
3232
3333 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 );
3835 }
3936
4037 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 );
4639 }
4740
4841 public static SqlTable of (String name ) {
Original file line number Diff line number Diff line change 11/**
2- * Copyright 2016-2017 the original author or authors.
2+ * Copyright 2016-2018 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -130,7 +130,11 @@ public void testNoAliasWithoutIgnore() {
130130 @ Test
131131 public void testTypeHandler () {
132132 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 ();
134138 IsEqualTo <Date > condition = IsEqualTo .of (() -> new Date ());
135139 SqlCriterion <Date > criterion = SqlCriterion .withColumn (column )
136140 .withCondition (condition )
You can’t perform that action at this time.
0 commit comments