View Javadoc
1   /**
2    *    Copyright 2009-2019 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 Clinton Begin
22   */
23  @Deprecated
24  public class SelectBuilder {
25  
26    private static final ThreadLocal<SQL> localSQL = new ThreadLocal<>();
27  
28    static {
29      BEGIN();
30    }
31  
32    private SelectBuilder() {
33      // Prevent Instantiation
34    }
35  
36    public static void BEGIN() {
37      RESET();
38    }
39  
40    public static void RESET() {
41      localSQL.set(new SQL());
42    }
43  
44    public static void SELECT(String columns) {
45      sql().SELECT(columns);
46    }
47  
48    public static void SELECT_DISTINCT(String columns) {
49      sql().SELECT_DISTINCT(columns);
50    }
51  
52    public static void FROM(String table) {
53      sql().FROM(table);
54    }
55  
56    public static void JOIN(String join) {
57      sql().JOIN(join);
58    }
59  
60    public static void INNER_JOIN(String join) {
61      sql().INNER_JOIN(join);
62    }
63  
64    public static void LEFT_OUTER_JOIN(String join) {
65      sql().LEFT_OUTER_JOIN(join);
66    }
67  
68    public static void RIGHT_OUTER_JOIN(String join) {
69      sql().RIGHT_OUTER_JOIN(join);
70    }
71  
72    public static void OUTER_JOIN(String join) {
73      sql().OUTER_JOIN(join);
74    }
75  
76    public static void WHERE(String conditions) {
77      sql().WHERE(conditions);
78    }
79  
80    public static void OR() {
81      sql().OR();
82    }
83  
84    public static void AND() {
85      sql().AND();
86    }
87  
88    public static void GROUP_BY(String columns) {
89      sql().GROUP_BY(columns);
90    }
91  
92    public static void HAVING(String conditions) {
93      sql().HAVING(conditions);
94    }
95  
96    public static void ORDER_BY(String columns) {
97      sql().ORDER_BY(columns);
98    }
99  
100   public static String SQL() {
101     try {
102       return sql().toString();
103     } finally {
104       RESET();
105     }
106   }
107 
108   private static SQL sql() {
109     return localSQL.get();
110   }
111 
112 }