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

java.lang.Object
  extended byorg.objectweb.jorm.mapper.rdb.adapter.BasicRdbAdapter
      extended byorg.objectweb.jorm.mapper.rdb.adapter.MysqlAdapter
All Implemented Interfaces:
PreparedStatementAdapter, RdbAdapter, ResultsetAdapter, SequenceAdapter, TypeAdapter, ValueAsSQLStringAdapter

public class MysqlAdapter
extends BasicRdbAdapter

MySql 4.0.12

Author:
S.Chassande-Barrioz

Field Summary
private static java.lang.String MYSQLINDEXEDLOCATE
           
 int varbinarySize
           
 int varbinarySizeInPk
           
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
MysqlAdapter()
           
 
Method Summary
 int fetchResultSetSize(java.sql.ResultSet rs)
          This calculates the size of a result set.
 java.lang.Object getArray(java.sql.ResultSet rs, int idx, java.lang.Object nullValue, int typeCode)
          Get an array value from a ResultSet.
 java.lang.String getArrayValueAsSQLString(java.lang.Object array, int typeCode, java.lang.String begin, java.lang.String realsep, java.lang.String end)
           
 char getChar(java.sql.ResultSet rs, int idx, char nullValue)
          Get a char value from a ResultSet.
 java.lang.String getCreateSequence(java.lang.String seqName)
           
 java.lang.String getCreateSequence(java.lang.String seqName, java.lang.Integer startid, java.lang.Integer inc, java.lang.Integer cache)
          CREATE [ TEMPORARY | TEMP ] SEQUENCE name [ INCREMENT [ BY ] increment ] [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ] [ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
 java.util.Date getDate(java.sql.ResultSet rs, int idx, java.lang.String sqlColumnType, java.util.Date nullValue)
          Get a Date value from a ResultSet.
 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.
 java.lang.Character getOchar(java.sql.ResultSet rs, int idx, java.lang.Character nullValue)
          Get a Character value from a ResultSet.
 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
 int getSqlTypeCode(int typeCode, java.lang.String sqlColumnType)
          This methods return the SQL type code linked to the java type specified in parameter.
protected  void modifyQueryWithRange(java.lang.StringBuffer sb, boolean rangeStart, boolean rangeSize)
           
protected  void modifySelectClauseWithRange(java.lang.StringBuffer sb, boolean rangeStart, boolean rangeSize)
           
 void setDate(java.sql.PreparedStatement ps, int idx, java.util.Date o, java.lang.String columnType)
          Assignes a String value into a PreparedStatement
 void setVarcharSize(int s)
           
 void setVarcharSizeInPk(int s)
           
 boolean supportArray(int elemTypeCode)
           
 boolean supportBatchPreparedStatement()
          Indicates if the driver supports the batch of PreparedStatement
 
Methods inherited from class org.objectweb.jorm.mapper.rdb.adapter.BasicRdbAdapter
appendClause, escapeFunctionClose, escapeFunctionOpen, existRelation, existSequence, existTable, existView, getArrayElementAsSQLString, getArrayToString, getArrayToStringBegin, getArrayToStringEnd, getArrayToStringSeparator, getArrayValueAsSQLString, getArrayValueAsSQLStringBegin, getArrayValueAsSQLStringEnd, getArrayValueAsSQLStringSeparator, getBigDecimal, getBigInteger, getBoolean, getByte, getByteArray, getCACHEkeyWord, getCharArray, getCharArray, getColumnAliasExpr, getConcatExpression, getDate, getDouble, getFirstLocateExpression, getFloat, getFromClause, getFromClause, getFromClause, getINCREMENTkeyWord, getInt, getLengthOperator, getLong, getManyNextValInSequence, getName, getNextValInSequence, getOboolean, getObyte, getOdouble, getOfloat, getOint, getOlong, getOshort, getQuery, getQuery, getSerialized, getShort, getSqlTypeCode, getSTARTkeyWord, getString, getSubqueryAlias, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, getValueAsSQLString, handleOrderBy, setArray, setBigDecimal, setBigInteger, setBoolean, setByte, setByteArray, setChar, setCharArray, setDouble, setFloat, setInt, setLogger, setLong, setNull, setOboolean, setObyte, setOchar, setOdouble, setOfloat, setOint, setOlong, setOshort, setSerialized, setShort, setString, writeColumnAlias, writeTableAlias
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MYSQLINDEXEDLOCATE

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

varcharSize

private int varcharSize

varcharSizeInPk

private int varcharSizeInPk

varbinarySize

public int varbinarySize

varbinarySizeInPk

public int varbinarySizeInPk
Constructor Detail

MysqlAdapter

public MysqlAdapter()
Method Detail

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

fetchResultSetSize

public int fetchResultSetSize(java.sql.ResultSet rs)
                       throws java.sql.SQLException
This calculates the size of a result set. If this feature is not supported by a database or its jdbc driver, this method returns -1.

Specified by:
fetchResultSetSize in interface RdbAdapter
Overrides:
fetchResultSetSize in class BasicRdbAdapter
Parameters:
rs - the result set which the size must be returned
Throws:
java.sql.SQLException

setVarcharSize

public void setVarcharSize(int s)

setVarcharSizeInPk

public void setVarcharSizeInPk(int s)

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

getSqlTypeCode

public int getSqlTypeCode(int typeCode,
                          java.lang.String sqlColumnType)
                   throws RdbAdapterException
Description copied from class: BasicRdbAdapter
This methods return the SQL type code linked to the java type specified in parameter.

Specified by:
getSqlTypeCode in interface TypeAdapter
Overrides:
getSqlTypeCode in class BasicRdbAdapter
Returns:
An int constant defined in the java.sql.Types class
Throws:
RdbAdapterException

getChar

public char getChar(java.sql.ResultSet rs,
                    int idx,
                    char nullValue)
             throws java.sql.SQLException
Description copied from interface: ResultsetAdapter
Get a char value from a ResultSet.

Specified by:
getChar in interface ResultsetAdapter
Overrides:
getChar in class BasicRdbAdapter
Throws:
java.sql.SQLException

getOchar

public java.lang.Character getOchar(java.sql.ResultSet rs,
                                    int idx,
                                    java.lang.Character nullValue)
                             throws java.sql.SQLException
Description copied from interface: ResultsetAdapter
Get a Character value from a ResultSet.

Specified by:
getOchar in interface ResultsetAdapter
Overrides:
getOchar in class BasicRdbAdapter
Throws:
java.sql.SQLException

getDate

public java.util.Date getDate(java.sql.ResultSet rs,
                              int idx,
                              java.lang.String sqlColumnType,
                              java.util.Date nullValue)
                       throws java.sql.SQLException
Description copied from interface: ResultsetAdapter
Get a Date value from a ResultSet.

Specified by:
getDate in interface ResultsetAdapter
Overrides:
getDate in class BasicRdbAdapter
Throws:
java.sql.SQLException

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

setDate

public void setDate(java.sql.PreparedStatement ps,
                    int idx,
                    java.util.Date o,
                    java.lang.String columnType)
             throws java.sql.SQLException
Description copied from interface: PreparedStatementAdapter
Assignes a String value into a PreparedStatement

Specified by:
setDate in interface PreparedStatementAdapter
Overrides:
setDate in class BasicRdbAdapter
Throws:
java.sql.SQLException

getCreateSequence

public java.lang.String getCreateSequence(java.lang.String seqName)
                                   throws java.lang.UnsupportedOperationException
Specified by:
getCreateSequence in interface SequenceAdapter
Overrides:
getCreateSequence in class BasicRdbAdapter
Throws:
java.lang.UnsupportedOperationException

getCreateSequence

public java.lang.String getCreateSequence(java.lang.String seqName,
                                          java.lang.Integer startid,
                                          java.lang.Integer inc,
                                          java.lang.Integer cache)
Description copied from class: BasicRdbAdapter
CREATE [ TEMPORARY | TEMP ] SEQUENCE name [ INCREMENT [ BY ] increment ] [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ] [ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]

Specified by:
getCreateSequence in interface SequenceAdapter
Overrides:
getCreateSequence in class BasicRdbAdapter
Parameters:
seqName -
startid -
inc -

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

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

getArray

public java.lang.Object getArray(java.sql.ResultSet rs,
                                 int idx,
                                 java.lang.Object nullValue,
                                 int typeCode)
                          throws java.sql.SQLException
Description copied from interface: ResultsetAdapter
Get an array value from a ResultSet.

Specified by:
getArray in interface ResultsetAdapter
Overrides:
getArray in class BasicRdbAdapter
Throws:
java.sql.SQLException

getArrayValueAsSQLString

public java.lang.String getArrayValueAsSQLString(java.lang.Object array,
                                                 int typeCode,
                                                 java.lang.String begin,
                                                 java.lang.String realsep,
                                                 java.lang.String end)
Overrides:
getArrayValueAsSQLString in class BasicRdbAdapter

supportArray

public boolean supportArray(int elemTypeCode)
Specified by:
supportArray in interface TypeAdapter
Overrides:
supportArray in class BasicRdbAdapter