org.objectweb.jorm.mapper.rdb.adapter
Class OracleAdapter

java.lang.Object
  extended byorg.objectweb.jorm.mapper.rdb.adapter.BasicRdbAdapter
      extended byorg.objectweb.jorm.mapper.rdb.adapter.OracleAdapter
All Implemented Interfaces:
PreparedStatementAdapter, RdbAdapter, ResultsetAdapter, SequenceAdapter, TypeAdapter, ValueAsSQLStringAdapter
Direct Known Subclasses:
Oracle8Adapter

public class OracleAdapter
extends BasicRdbAdapter

Author:
S.Chassande-Barrioz

Field Summary
private  int defaultBytearraySize
           
private  int defaultChararraySize
           
private  java.lang.String[] GROUP_FUNCTIONS
           
private static java.lang.String ORACLEFIRSTLOCATE
           
private static java.lang.String PROP_BASE
           
static java.util.Map properties
           
static java.lang.String[][] PROPS
           
private  int varcharSize
           
private  int varcharSizeInPk
           
 
Fields inherited from class org.objectweb.jorm.mapper.rdb.adapter.BasicRdbAdapter
logger, name
 
Fields inherited from interface org.objectweb.jorm.mapper.rdb.adapter.api.RdbAdapter
NOSIZE, RANGEATEND, RANGEATSTART, RANGEUNSUPPORTED
 
Fields inherited from interface org.objectweb.jorm.mapper.rdb.adapter.api.TypeAdapter
TYPE_NAMES, TYPECODE_ARRAY, TYPECODE_BIGDECIMAL, TYPECODE_BIGINTEGER, TYPECODE_BOOLEAN, TYPECODE_BYTE, TYPECODE_BYTEARRAY, TYPECODE_CHAR, TYPECODE_CHARARRAY, TYPECODE_DATE, TYPECODE_DOUBLE, TYPECODE_FLOAT, TYPECODE_INT, TYPECODE_LONG, TYPECODE_OBJBOOLEAN, TYPECODE_OBJBYTE, TYPECODE_OBJCHAR, TYPECODE_OBJDOUBLE, TYPECODE_OBJFLOAT, TYPECODE_OBJINT, TYPECODE_OBJLONG, TYPECODE_OBJSHORT, TYPECODE_SERIALIZED, TYPECODE_SHORT, TYPECODE_STRING
 
Constructor Summary
OracleAdapter()
           
OracleAdapter(java.lang.String name)
           
 
Method Summary
private  boolean containGroupFunction(java.lang.String selectClause)
           
protected  boolean existRelation(java.sql.Connection connection, java.lang.String relName, java.lang.String[] relationTypes)
           
 boolean existSequence(java.sql.Connection connection, java.lang.String seqName)
          checks the sequence existence
 java.lang.String getColumnAliasExpr(java.lang.String aliasName)
          Returns a column alias expression.
private static int getDefaultSize(int idx)
           
 java.lang.String getFirstLocateExpression(java.lang.String substring, java.lang.String instring)
          Returns the expression for searching the position of the first occurrence of a substring in a string.
 java.lang.String getIndexedLocateExpression(java.lang.String instring, java.lang.String substring, java.lang.String fromIndex)
          Returns the expression for searching the position of the first occurrence of a substring in a string starting from a given index.
 void getManyNextValInSequence(java.sql.Connection conn, java.lang.String seqName, int numberOfNextVal)
           
 java.lang.String getNextValInSequence(java.lang.String seqName)
           
 java.lang.String getQuery(java.lang.String selectClause, java.lang.String fromClause, java.lang.String whereClause, java.lang.String orderBy, java.lang.String groupBy, boolean rangeStart, boolean rangeSize)
          Builds a query with join and table alias.
 int getRangeParametersAtStart()
          Indicates whether parameters corresponding to range queries (range start and size) are positioned at the start or at the end of the SQL query.
 java.lang.String getSqlType(int typeCode, boolean usedInPK, int size, int scale)
          This method returns the SQL type linked to the java type
 java.lang.String getValueAsSQLString(java.lang.Object value, int typeCode)
          This method returns a String value that represents a value.
 java.lang.String handleOrderBy(java.lang.String query)
           
protected  void modifyQueryWithRange(java.lang.StringBuffer sb, boolean rangeStart, boolean rangeSize)
           
protected  void modifySelectClauseWithRange(java.lang.StringBuffer sb, boolean rangeStart, boolean rangeSize)
           
 void setVarcharSize(int s)
           
 void setVarcharSizeInPk(int s)
           
 boolean supportBatchPreparedStatement()
          Indicates if the driver supports the batch of PreparedStatement
 void writeColumnAlias(java.lang.String alias, java.lang.StringBuffer sb)
          Append a column alias to an SQL expression.
 void writeTableAlias(java.lang.String alias, java.lang.StringBuffer sb)
          Append a table alias to an SQL expression.
 
Methods inherited from class org.objectweb.jorm.mapper.rdb.adapter.BasicRdbAdapter
appendClause, escapeFunctionClose, escapeFunctionOpen, existTable, existView, fetchResultSetSize, getArray, getArrayElementAsSQLString, getArrayToString, getArrayToStringBegin, getArrayToStringEnd, getArrayToStringSeparator, getArrayValueAsSQLString, getArrayValueAsSQLString, getArrayValueAsSQLStringBegin, getArrayValueAsSQLStringEnd, getArrayValueAsSQLStringSeparator, getBigDecimal, getBigInteger, getBoolean, getByte, getByteArray, getCACHEkeyWord, getChar, getCharArray, getCharArray, getConcatExpression, getCreateSequence, getCreateSequence, getDate, getDate, getDouble, getFloat, getFromClause, getFromClause, getFromClause, getINCREMENTkeyWord, getInt, getLengthOperator, getLong, getName, getOboolean, getObyte, getOchar, getOdouble, getOfloat, getOint, getOlong, getOshort, getQuery, getSerialized, getShort, getSqlTypeCode, getSqlTypeCode, getSTARTkeyWord, getString, getSubqueryAlias, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, setArray, setBigDecimal, setBigInteger, setBoolean, setByte, setByteArray, setChar, setCharArray, setDate, setDouble, setFloat, setInt, setLogger, setLong, setNull, setOboolean, setObyte, setOchar, setOdouble, setOfloat, setOint, setOlong, setOshort, setSerialized, setShort, setString, supportArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_BASE

private static final java.lang.String PROP_BASE
See Also:
Constant Field Values

ORACLEFIRSTLOCATE

private static final java.lang.String ORACLEFIRSTLOCATE
See Also:
Constant Field Values

PROPS

public static final java.lang.String[][] PROPS

properties

public static final java.util.Map properties

varcharSize

private int varcharSize

defaultBytearraySize

private int defaultBytearraySize

defaultChararraySize

private int defaultChararraySize

varcharSizeInPk

private int varcharSizeInPk

GROUP_FUNCTIONS

private final java.lang.String[] GROUP_FUNCTIONS
Constructor Detail

OracleAdapter

public OracleAdapter()

OracleAdapter

public OracleAdapter(java.lang.String name)
Method Detail

getDefaultSize

private static final int getDefaultSize(int idx)

setVarcharSize

public void setVarcharSize(int s)

setVarcharSizeInPk

public void setVarcharSizeInPk(int s)

supportBatchPreparedStatement

public boolean supportBatchPreparedStatement()
Description copied from interface: RdbAdapter
Indicates if the driver supports the batch of PreparedStatement

Specified by:
supportBatchPreparedStatement in interface RdbAdapter
Overrides:
supportBatchPreparedStatement in class BasicRdbAdapter

getSqlType

public java.lang.String getSqlType(int typeCode,
                                   boolean usedInPK,
                                   int size,
                                   int scale)
                            throws RdbAdapterException
Description copied from interface: TypeAdapter
This method returns the SQL type linked to the java type

Specified by:
getSqlType in interface TypeAdapter
Overrides:
getSqlType in class BasicRdbAdapter
Throws:
RdbAdapterException

getFirstLocateExpression

public java.lang.String getFirstLocateExpression(java.lang.String substring,
                                                 java.lang.String instring)
Description copied from interface: RdbAdapter
Returns the expression for searching the position of the first occurrence of a substring in a string.

Three main syntaxes are found: position(substr in str), locate(substr, srt) and instr(str, substr).

Specified by:
getFirstLocateExpression in interface RdbAdapter
Overrides:
getFirstLocateExpression in class BasicRdbAdapter

getIndexedLocateExpression

public java.lang.String getIndexedLocateExpression(java.lang.String instring,
                                                   java.lang.String substring,
                                                   java.lang.String fromIndex)
Description copied from interface: RdbAdapter
Returns the expression for searching the position of the first occurrence of a substring in a string starting from a given index.

Two main syntaxes are found: instr() and locate()

Specified by:
getIndexedLocateExpression in interface RdbAdapter
Overrides:
getIndexedLocateExpression in class BasicRdbAdapter

writeTableAlias

public void writeTableAlias(java.lang.String alias,
                            java.lang.StringBuffer sb)
Description copied from interface: RdbAdapter
Append a table alias to an SQL expression. To be used when constructing the string expression of a from clause. For example, most database recognize the syntax 'select ... from R as ALIAS_FOR_R, S as ALIAS_FOR_S ... ' whereas Orabcle accepts the following syntax : 'select ... from R ALIAS_FOR_R, S ALIAS_FOR_S ... '

Specified by:
writeTableAlias in interface RdbAdapter
Overrides:
writeTableAlias in class BasicRdbAdapter

getColumnAliasExpr

public java.lang.String getColumnAliasExpr(java.lang.String aliasName)
Description copied from interface: RdbAdapter
Returns a column alias expression. To be used when constructing the string expression of a select clause. For example, most database recognize the syntax 'select A as ALIAS_FOR_A, B as ALIAS_FOR_B ... ' whereas Orabcle accepts the following syntax : 'select A "ALIAS_FOR_A", B "ALIAS_FOR_B" '

Specified by:
getColumnAliasExpr in interface RdbAdapter
Overrides:
getColumnAliasExpr in class BasicRdbAdapter

writeColumnAlias

public void writeColumnAlias(java.lang.String alias,
                             java.lang.StringBuffer sb)
Description copied from interface: RdbAdapter
Append a column alias to an SQL expression. To be used when constructing the string expression of a select clause. For example, most database recognize the syntax 'select A as ALIAS_FOR_A, B as ALIAS_FOR_B ... ' whereas Orabcle accepts the following syntax : 'select A "ALIAS_FOR_A", B "ALIAS_FOR_B" '

Specified by:
writeColumnAlias in interface RdbAdapter
Overrides:
writeColumnAlias in class BasicRdbAdapter

handleOrderBy

public java.lang.String handleOrderBy(java.lang.String query)
Specified by:
handleOrderBy in interface RdbAdapter
Overrides:
handleOrderBy in class BasicRdbAdapter

getNextValInSequence

public java.lang.String getNextValInSequence(java.lang.String seqName)
Specified by:
getNextValInSequence in interface SequenceAdapter
Overrides:
getNextValInSequence in class BasicRdbAdapter

getManyNextValInSequence

public void getManyNextValInSequence(java.sql.Connection conn,
                                     java.lang.String seqName,
                                     int numberOfNextVal)
                              throws RdbAdapterException
Specified by:
getManyNextValInSequence in interface SequenceAdapter
Overrides:
getManyNextValInSequence in class BasicRdbAdapter
Throws:
RdbAdapterException

existRelation

protected boolean existRelation(java.sql.Connection connection,
                                java.lang.String relName,
                                java.lang.String[] relationTypes)
                         throws java.sql.SQLException
Overrides:
existRelation in class BasicRdbAdapter
Throws:
java.sql.SQLException

existSequence

public boolean existSequence(java.sql.Connection connection,
                             java.lang.String seqName)
                      throws java.sql.SQLException
Description copied from interface: SequenceAdapter
checks the sequence existence

Specified by:
existSequence in interface SequenceAdapter
Overrides:
existSequence in class BasicRdbAdapter
Throws:
java.sql.SQLException

getQuery

public java.lang.String getQuery(java.lang.String selectClause,
                                 java.lang.String fromClause,
                                 java.lang.String whereClause,
                                 java.lang.String orderBy,
                                 java.lang.String groupBy,
                                 boolean rangeStart,
                                 boolean rangeSize)
Description copied from interface: RdbAdapter
Builds a query with join and table alias. The implementation must use writeTableAlias(String StringBuffer) method.

Specified by:
getQuery in interface RdbAdapter
Overrides:
getQuery in class BasicRdbAdapter

modifySelectClauseWithRange

protected void modifySelectClauseWithRange(java.lang.StringBuffer sb,
                                           boolean rangeStart,
                                           boolean rangeSize)
Overrides:
modifySelectClauseWithRange in class BasicRdbAdapter

modifyQueryWithRange

protected void modifyQueryWithRange(java.lang.StringBuffer sb,
                                    boolean rangeStart,
                                    boolean rangeSize)
Overrides:
modifyQueryWithRange in class BasicRdbAdapter

containGroupFunction

private boolean containGroupFunction(java.lang.String selectClause)

getRangeParametersAtStart

public int getRangeParametersAtStart()
Description copied from interface: RdbAdapter
Indicates whether parameters corresponding to range queries (range start and size) are positioned at the start or at the end of the SQL query.

Indeed, depending on the database, the SQL syntax may vary, and the parameters can either be put at the front or at the end.

Specified by:
getRangeParametersAtStart in interface RdbAdapter
Overrides:
getRangeParametersAtStart in class BasicRdbAdapter

getValueAsSQLString

public java.lang.String getValueAsSQLString(java.lang.Object value,
                                            int typeCode)
Description copied from interface: ValueAsSQLStringAdapter
This method returns a String value that represents a value. This method can be used for the constant parameters of SQL queries.

Specified by:
getValueAsSQLString in interface ValueAsSQLStringAdapter
Overrides:
getValueAsSQLString in class BasicRdbAdapter