View Javadoc
1   /**
2    *    Copyright 2009-2018 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.jdbc;
17  
18  /**
19   * @deprecated Use the {@link SQL} Class
20   *
21   * @author Jeff Butler
22   */
23  public class SqlBuilder {
24  
25    private static final ThreadLocal<SQL> localSQL = new ThreadLocal<>();
26  
27    static {
28      BEGIN();
29    }
30  
31    private SqlBuilder() {
32      // Prevent Instantiation
33    }
34  
35    public static void BEGIN() {
36      RESET();
37    }
38  
39    public static void RESET() {
40      localSQL.set(new SQL());
41    }
42  
43    public static void UPDATE(String table) {
44      sql().UPDATE(table);
45    }
46  
47    public static void SET(String sets) {
48      sql().SET(sets);
49    }
50  
51    public static String SQL() {
52      try {
53        return sql().toString();
54      } finally {
55          RESET();
56      }
57    }
58  
59    public static void INSERT_INTO(String tableName) {
60      sql().INSERT_INTO(tableName);
61    }
62  
63    public static void VALUES(String columns, String values) {
64      sql().VALUES(columns, values);
65    }
66  
67    public static void SELECT(String columns) {
68      sql().SELECT(columns);
69    }
70  
71    public static void SELECT_DISTINCT(String columns) {
72      sql().SELECT_DISTINCT(columns);
73    }
74  
75    public static void DELETE_FROM(String table) {
76      sql().DELETE_FROM(table);
77    }
78  
79    public static void FROM(String table) {
80      sql().FROM(table);
81    }
82  
83    public static void JOIN(String join) {
84      sql().JOIN(join);
85    }
86  
87    public static void INNER_JOIN(String join) {
88      sql().INNER_JOIN(join);
89    }
90  
91    public static void LEFT_OUTER_JOIN(String join) {
92      sql().LEFT_OUTER_JOIN(join);
93    }
94  
95    public static void RIGHT_OUTER_JOIN(String join) {
96      sql().RIGHT_OUTER_JOIN(join);
97    }
98  
99    public static void OUTER_JOIN(String join) {
100     sql().OUTER_JOIN(join);
101   }
102 
103   public static void WHERE(String conditions) {
104     sql().WHERE(conditions);
105   }
106 
107   public static void OR() {
108     sql().OR();
109   }
110 
111   public static void AND() {
112     sql().AND();
113   }
114 
115   public static void GROUP_BY(String columns) {
116     sql().GROUP_BY(columns);
117   }
118 
119   public static void HAVING(String conditions) {
120     sql().HAVING(conditions);
121   }
122 
123   public static void ORDER_BY(String columns) {
124     sql().ORDER_BY(columns);
125   }
126 
127   private static SQL sql() {
128     return localSQL.get();
129   }
130 
131 }