SqlBuilder.java

  1. /*
  2.  *    Copyright 2009-2022 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.  *       https://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.  * @deprecated Use the {@link SQL} Class
  19.  *
  20.  * @author Jeff Butler
  21.  */
  22. @Deprecated
  23. public class SqlBuilder {

  24.   private static final ThreadLocal<SQL> localSQL = new ThreadLocal<>();

  25.   static {
  26.     BEGIN();
  27.   }

  28.   private SqlBuilder() {
  29.     // Prevent Instantiation
  30.   }

  31.   public static void BEGIN() {
  32.     RESET();
  33.   }

  34.   public static void RESET() {
  35.     localSQL.set(new SQL());
  36.   }

  37.   public static void UPDATE(String table) {
  38.     sql().UPDATE(table);
  39.   }

  40.   public static void SET(String sets) {
  41.     sql().SET(sets);
  42.   }

  43.   public static String SQL() {
  44.     try {
  45.       return sql().toString();
  46.     } finally {
  47.       RESET();
  48.     }
  49.   }

  50.   public static void INSERT_INTO(String tableName) {
  51.     sql().INSERT_INTO(tableName);
  52.   }

  53.   public static void VALUES(String columns, String values) {
  54.     sql().VALUES(columns, values);
  55.   }

  56.   public static void SELECT(String columns) {
  57.     sql().SELECT(columns);
  58.   }

  59.   public static void SELECT_DISTINCT(String columns) {
  60.     sql().SELECT_DISTINCT(columns);
  61.   }

  62.   public static void DELETE_FROM(String table) {
  63.     sql().DELETE_FROM(table);
  64.   }

  65.   public static void FROM(String table) {
  66.     sql().FROM(table);
  67.   }

  68.   public static void JOIN(String join) {
  69.     sql().JOIN(join);
  70.   }

  71.   public static void INNER_JOIN(String join) {
  72.     sql().INNER_JOIN(join);
  73.   }

  74.   public static void LEFT_OUTER_JOIN(String join) {
  75.     sql().LEFT_OUTER_JOIN(join);
  76.   }

  77.   public static void RIGHT_OUTER_JOIN(String join) {
  78.     sql().RIGHT_OUTER_JOIN(join);
  79.   }

  80.   public static void OUTER_JOIN(String join) {
  81.     sql().OUTER_JOIN(join);
  82.   }

  83.   public static void WHERE(String conditions) {
  84.     sql().WHERE(conditions);
  85.   }

  86.   public static void OR() {
  87.     sql().OR();
  88.   }

  89.   public static void AND() {
  90.     sql().AND();
  91.   }

  92.   public static void GROUP_BY(String columns) {
  93.     sql().GROUP_BY(columns);
  94.   }

  95.   public static void HAVING(String conditions) {
  96.     sql().HAVING(conditions);
  97.   }

  98.   public static void ORDER_BY(String columns) {
  99.     sql().ORDER_BY(columns);
  100.   }

  101.   private static SQL sql() {
  102.     return localSQL.get();
  103.   }

  104. }