001: package org.apache.torque.adapter;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import java.sql.Connection;
023: import java.sql.SQLException;
024:
025: /**
026: * This is used to connect to Hypersonic SQL databases.
027: *
028: * <a href="http://hsqldb.org/">http://hsqldb.org/</a>
029: *
030: * @author <a href="mailto:celkins@scardini.com">Christopher Elkins</a>
031: * @version $Id: DBHypersonicSQL.java 476550 2006-11-18 16:08:37Z tfischer $
032: */
033: public class DBHypersonicSQL extends AbstractDBAdapter {
034: /**
035: * Serial version
036: */
037: private static final long serialVersionUID = 8392727399615702372L;
038:
039: /**
040: * Constructor.
041: */
042: protected DBHypersonicSQL() {
043: }
044:
045: /**
046: * This method is used to ignore case.
047: *
048: * @param in The string to transform to upper case.
049: * @return The upper case string.
050: */
051: public String toUpperCase(String in) {
052: String s = new StringBuffer("UPPER(").append(in).append(")")
053: .toString();
054: return s;
055: }
056:
057: /**
058: * This method is used to ignore case.
059: *
060: * @param in The string whose case to ignore.
061: * @return The string in a case that can be ignored.
062: */
063: public String ignoreCase(String in) {
064: return toUpperCase(in);
065: }
066:
067: /**
068: * @see org.apache.torque.adapter.DB#getIDMethodType()
069: */
070: public String getIDMethodType() {
071: return AUTO_INCREMENT;
072: }
073:
074: /**
075: * @see org.apache.torque.adapter.DB#ignoreCaseInOrderBy(String)
076: */
077: public String ignoreCaseInOrderBy(String in) {
078: return "CAST(" + in + " AS VARCHAR_IGNORECASE)";
079: }
080:
081: /**
082: * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
083: */
084: public String getIDMethodSQL(Object obj) {
085: StringBuffer command = new StringBuffer(
086: "select IDENTITY() from ");
087: String qualifiedIdentifier = (String) obj;
088: command.append(qualifiedIdentifier);
089: return command.toString();
090: }
091:
092: /**
093: * Locks the specified table.
094: *
095: * @param con The JDBC connection to use.
096: * @param table The name of the table to lock.
097: * @exception SQLException No Statement could be created or executed.
098: */
099: public void lockTable(Connection con, String table)
100: throws SQLException {
101: }
102:
103: /**
104: * Unlocks the specified table.
105: *
106: * @param con The JDBC connection to use.
107: * @param table The name of the table to unlock.
108: * @exception SQLException No Statement could be created or executed.
109: */
110: public void unlockTable(Connection con, String table)
111: throws SQLException {
112: }
113:
114: /**
115: * This method is for the SqlExpression.quoteAndEscape rules. The rule is,
116: * any string in a SqlExpression with a BACKSLASH will either be changed to
117: * "\\" or left as "\".
118: *
119: * @return false.
120: */
121: public boolean escapeText() {
122: return false;
123: }
124:
125: /**
126: * Whether an escape clause in like should be used.
127: * Example : select * from AUTHOR where AUTHOR.NAME like '\_%' ESCAPE '\';
128: *
129: * HSQLDB needs this, so this implementation always returns
130: * <code>true</code>.
131: *
132: * @return whether the escape clause should be appended or not.
133: */
134: public boolean useEscapeClauseForLike() {
135: return true;
136: }
137: }
|