arminw 2005/08/27 05:23:42
Modified: src/java/org/apache/ojb/broker/platforms Platform.java
PlatformDb2Impl.java PlatformDefaultImpl.java
PlatformFactory.java PlatformHsqldbImpl.java
PlatformOracleImpl.java PlatformPostgreSQLImpl.java
PlatformSapdbImpl.java PlatformWLOracle9iImpl.java
Log:
merge 1.0.x branch with 1.x trunk
Revision Changes Path
1.27 +43 -39
db-ojb/src/java/org/apache/ojb/broker/platforms/Platform.java
Index: Platform.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/Platform.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- Platform.java 6 Apr 2005 14:45:42 -0000 1.26
+++ Platform.java 27 Aug 2005 12:23:42 -0000 1.27
@@ -24,12 +24,13 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.Properties;
/**
- * this interface provides callbacks that allow to perform
- * RDBMS Platform specific operations whereever neccessary.
- * The Platform implementation is selected by the <dbms.name></dbms.name>
- * entry in the repository.xml file.
+ * This interface provides callbacks that allow to perform
+ * RDBMS Platform specific operations wherever neccessary.
+ * The Platform implementation is selected by the platform attribute for
+ * each jdbc-connection-descriptor entry in the repository file.
*
* @version $Id$
* @author Thomas Mahler
@@ -37,46 +38,46 @@
public interface Platform
{
/**
- * Called after a jdbc-m_connection statement was created.
+ * Called after a statement has been created.
*/
public void afterStatementCreate(Statement stmt) throws
PlatformException;
/**
* Called by [EMAIL PROTECTED]
org.apache.ojb.broker.accesslayer.StatementManager} implementation
- * before invoke <tt>stmt.close()</tt> method.
+ * before invoking <tt>stmt.close()</tt> method.
*/
public void beforeStatementClose(Statement stmt, ResultSet rs) throws
PlatformException;
/**
* Called by [EMAIL PROTECTED]
org.apache.ojb.broker.accesslayer.StatementManager} implementation
- * after invoke <tt>stmt.close()</tt> method.
+ * after invoking <tt>stmt.close()</tt> method.
*/
public void afterStatementClose(Statement stmt, ResultSet rs) throws
PlatformException;
/**
- *
+ * Called before batching operations on a statement.
* @param stmt the statement you want to batch on
* @throws PlatformException
*/
public void beforeBatch(PreparedStatement stmt) throws PlatformException;
/**
- *
+ * Called when adding statements to current batch.
* @param stmt the statement you are adding to the batch
* @throws PlatformException
*/
public void addBatch(PreparedStatement stmt) throws PlatformException;
/**
- *
+ * Executes current batch.
* @param stmt the statement you want to execute the batch on
* @throws PlatformException
*/
public int[] executeBatch(PreparedStatement stmt) throws
PlatformException;
/**
- * callback called immediately after a JDBC Connection has been obtained
- * in ...
+ * Called immediately after a JDBC connection has been created by a
+ * ConnectionFactory implementation (not used for DataSource
connections).
* @param conn the Connection to be initialized
*/
public void initializeJdbcConnection(JdbcConnectionDescriptor jcd,
Connection conn) throws PlatformException;
@@ -93,21 +94,25 @@
public void changeAutoCommitState(JdbcConnectionDescriptor jcd,
Connection con, boolean newState);
/**
- * some JDBC-Drivers do not support all sqlTypes
- * this callback is used set parameters to a PreparedStatement
+ * Called to let the Platform implementation perform any JDBC
type-specific operations
+ * needed by the driver when binding positional parameters for a
PreparedStatement.
*/
public void setObjectForStatement(PreparedStatement ps, int index,
Object value, int sqlType)
throws SQLException;
/**
- * some JDBC-Drivers do not support all sqlTypes
- * this callback is used set parameters to a PreparedStatement
+ * Called to let the Platform implementation perform any JDBC
type-specific operations
+ * needed by the driver when binding null parameters for a
PreparedStatement.
*/
public void setNullForStatement(PreparedStatement ps, int index, int
sqlType)
throws SQLException;
/**
- * Get join syntax type for this RDBMS - one on of the constants from
JoinSyntaxType interface
+ * Get join syntax type for this RDBMS - one of the constants from
JoinSyntaxTypes interface.
+ * @see
org.apache.ojb.broker.accesslayer.JoinSyntaxTypes#SQL92_JOIN_SYNTAX
+ * @see
org.apache.ojb.broker.accesslayer.JoinSyntaxTypes#SQL92_NOPAREN_JOIN_SYNTAX
+ * @see
org.apache.ojb.broker.accesslayer.JoinSyntaxTypes#ORACLE_JOIN_SYNTAX
+ * @see
org.apache.ojb.broker.accesslayer.JoinSyntaxTypes#SYBASE_JOIN_SYNTAX
*/
public byte getJoinSyntaxType();
@@ -118,7 +123,7 @@
public boolean useCountForResultsetSize();
/**
- * if this platform supports the batch operations jdbc 2.0 feature. This
is
+ * If this platform supports the batch operations jdbc 2.0 feature. This
is
* by driver, so we check the driver's metadata once and set something in
* the platform.
* @return true if the platform supports batch, false otherwise.
@@ -136,9 +141,21 @@
/**
* Returns a query to create a sequence entry.
+ *
+ * @param sequenceName The name of the sequence to create.
+ * @param prop The database specific sequence properties.
+ * @return a sql string to create a sequence
+ */
+ String createSequenceQuery(String sequenceName, Properties prop);
+
+ /**
+ * Returns a query to create a sequence entry.
+ *
+ * @param sequenceName The name of the sequence to create.
* @return a sql string to create a sequence
+ * @deprecated use [EMAIL PROTECTED] #createSequenceQuery(String)}
instead.
*/
- public String createSequenceQuery(String sequenceName);
+ String createSequenceQuery(String sequenceName);
/**
* Returns a query to obtain the next sequence key.
@@ -179,23 +196,21 @@
/**
* Answer true if LIMIT or equivalent is supported
* <b> SQL-Paging is not yet supported </b>
- * @return
*/
public boolean supportsPaging();
-
+
/**
* Add the LIMIT or equivalent to the SQL
* <b> SQL-Paging is not yet supported </b>
*/
public void addPagingSql(StringBuffer anSqlString);
-
+
/**
* Answer true if the LIMIT parameters are bound before the query
parameters
* <b> SQL-Paging is not yet supported </b>
- * @return
*/
- boolean bindPagingParametersFirst();
-
+ public boolean bindPagingParametersFirst();
+
/**
* Bind the Paging Parameters
* <b> SQL-Paging is not yet supported </b>
@@ -203,10 +218,9 @@
* @param index parameter index
* @param startAt
* @param endAt
- * @return
*/
public int bindPagingParameters(PreparedStatement ps, int index, int
startAt, int endAt) throws SQLException;
-
+
/**
* Concatenate the columns </br>
* ie: col1 || col2 || col3 (ANSI)</br>
@@ -217,11 +231,10 @@
* @return the concatenated String
*/
public String concatenate(String[] theColumns);
-
+
/**
* Answer the Clause used Escape wildcards in LIKE
* @param aCriteria
- * @return
*/
public String getEscapeClause(LikeCriteria aCriteria);
@@ -229,19 +242,10 @@
* Answer the quoted name ie. "table" or [table] etc.
* <b> not yet supported </b>
* @param aString
- * @return
*/
public String quoteName(String aString);
/**
- * Determines whether statement is [EMAIL PROTECTED] CallableStatement}
or not.
- *
- * @param stmt the statement
- * @return true if statement is [EMAIL PROTECTED] CallableStatement}.
- */
- public boolean isCallableStatement(PreparedStatement stmt);
-
- /**
* Registers call argument at <code>position</code> as returning
* a [EMAIL PROTECTED] ResultSet} value.
*
1.12 +180 -1
db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDb2Impl.java
Index: PlatformDb2Impl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDb2Impl.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- PlatformDb2Impl.java 30 Jul 2004 16:04:18 -0000 1.11
+++ PlatformDb2Impl.java 27 Aug 2005 12:23:42 -0000 1.12
@@ -18,11 +18,102 @@
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
+import java.util.Properties;
+
+import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
/**
* This class extends <code>PlatformDefaultImpl</code> and defines specific
* behavior for the DB2 platform.
*
+ * <p/>
+ * Many of the database sequence specific properties can be specified using
+ * <em>custom attributes</em> within the <em>sequence-manager</em> element.
+ * <br/>
+ * The database sequence specific properties are generally speaking, see
database user guide
+ * for detailed description.
+ *
+ * <p>
+ * Supported properties on sequence creation:
+ * </p>
+ *
+ * <table cellspacing="2" cellpadding="2" border="3" frame="box">
+ * <tr>
+ * <td><strong>Property Key</strong></td>
+ * <td><strong>Property Values</strong></td>
+ * </tr>
+ * <tr>
+ * <td>seq.as</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the datatype used for the sequence.
+ * Allowed: all numeric datatypes? e.g. <em>INTEGER</em>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.start</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the first sequence number to be
+ * generated. Allowed: <em>1</em> or greater.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.incrementBy</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the interval between sequence numbers.
+ * This value can be any positive or negative
+ * integer, but it cannot be 0.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.maxValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set max value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.minValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set min value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cycle</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If <em>true</em>, specifies that the sequence continues to
generate
+ * values after reaching either its maximum or minimum value.
+ * <br/>
+ * If <em>false</em>, specifies that the sequence cannot generate
more values after
+ * reaching its maximum or minimum value.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cache</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies how many values of the sequence Oracle
+ * preallocates and keeps in memory for faster access.
+ * Allowed values: <em>2</em> or greater. If set <em>0</em>,
+ * an explicite <em>nocache</em> expression will be set.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.order</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If set <em>true</em>, guarantees that sequence numbers
+ * are generated in order of request.
+ * <br/>
+ * If <em>false</em>, a <em>no order</em> expression will be set.
+ * </td>
+ * </tr>
+ * </table>
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Thomas Mahler<a>
* @version $Id$
*/
@@ -50,6 +141,94 @@
return "create sequence " + sequenceName;
}
+ public String createSequenceQuery(String sequenceName, Properties prop)
+ {
+ /*
+ Read syntax diagramSkip visual syntax diagram
+ .-AS INTEGER----.
+ >>-CREATE SEQUENCE--sequence-name--*--+---------------+--*------>
+ '-AS--data-type-'
+
+ >--+------------------------------+--*-------------------------->
+ '-START WITH--numeric-constant-'
+
+ .-INCREMENT BY 1-----------------.
+ >--+--------------------------------+--*------------------------>
+ '-INCREMENT BY--numeric-constant-'
+
+ .-NO MINVALUE----------------.
+ >--+----------------------------+--*---------------------------->
+ '-MINVALUE--numeric-constant-'
+
+ .-NO MAXVALUE----------------. .-NO CYCLE-.
+ >--+----------------------------+--*--+----------+--*----------->
+ '-MAXVALUE--numeric-constant-' '-CYCLE----'
+
+ .-CACHE 20----------------. .-NO ORDER-.
+ >--+-------------------------+--*--+----------+--*-------------><
+ +-CACHE--integer-constant-+ '-ORDER----'
+ '-NO CACHE----------------'
+ */
+ StringBuffer query = new
StringBuffer(createSequenceQuery(sequenceName));
+ if(prop != null)
+ {
+ Boolean b;
+ Long value;
+ String str;
+
+ str = SequenceManagerHelper.getSeqAsValue(prop);
+ if(str != null)
+ {
+ query.append(" AS ").append(str);
+ }
+
+ value = SequenceManagerHelper.getSeqStart(prop);
+ if(value != null)
+ {
+ query.append(" START WITH ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqIncrementBy(prop);
+ if(value != null)
+ {
+ query.append(" INCREMENT BY ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqMinValue(prop);
+ if(value != null)
+ {
+ query.append(" MINVALUE ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqMaxValue(prop);
+ if(value != null)
+ {
+ query.append(" MAXVALUE ").append(value.longValue());
+ }
+
+ b = SequenceManagerHelper.getSeqCycleValue(prop);
+ if(b != null)
+ {
+ if(b.booleanValue()) query.append(" CYCLE");
+ else query.append(" NO CYCLE");
+ }
+
+ value = SequenceManagerHelper.getSeqCacheValue(prop);
+ if(value != null)
+ {
+ query.append(" CACHE ").append(value.longValue());
+ }
+
+ b = SequenceManagerHelper.getSeqOrderValue(prop);
+ if(b != null)
+ {
+ if(b.booleanValue()) query.append(" ORDER");
+ else query.append(" NO ORDER");
+ }
+ }
+ return query.toString();
+ }
+
public String nextSequenceQuery(String sequenceName)
{
return "values nextval for "+ sequenceName;
1.32 +28 -26
db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java
Index: PlatformDefaultImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- PlatformDefaultImpl.java 6 Apr 2005 14:45:42 -0000 1.31
+++ PlatformDefaultImpl.java 27 Aug 2005 12:23:42 -0000 1.32
@@ -24,6 +24,7 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
+import java.util.Properties;
import org.apache.ojb.broker.PersistenceBrokerException;
import org.apache.ojb.broker.accesslayer.JoinSyntaxTypes;
@@ -43,10 +44,11 @@
*/
public class PlatformDefaultImpl implements Platform, JoinSyntaxTypes
{
+ protected Logger log =
LoggerFactory.getLogger(PlatformDefaultImpl.class);
private static final char OJB_QUOTE_BEGIN_CHAR = '\'';
private static final char OJB_QUOTE_END_CHAR = '\'';
-
- protected Logger log =
LoggerFactory.getLogger(PlatformDefaultImpl.class);
+ private static final String INITIALIZATION_CHECK_AUTOCOMMIT =
"initializationCheck";
+ private static final String FALSE_STR = "false";
protected boolean m_batchUpdatesChecked = false;
protected boolean m_supportsBatchUpdates = false;
@@ -67,7 +69,7 @@
{
if (!m_batchUpdatesChecked)
{
- DatabaseMetaData meta = null;
+ DatabaseMetaData meta;
try
{
meta = conn.getMetaData();
@@ -146,6 +148,7 @@
public void initializeJdbcConnection(JdbcConnectionDescriptor jcd,
Connection conn) throws PlatformException
{
if (jcd.getBatchMode()) checkForBatchSupport(conn);
+
switch (jcd.getUseAutoCommit())
{
case JdbcConnectionDescriptor.AUTO_COMMIT_IGNORE_STATE:
@@ -154,7 +157,17 @@
case
JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE:
try
{
- if (!conn.getAutoCommit()) conn.setAutoCommit(true);
+ /*
+ arminw:
+ workaround to be backward compatible. In future releases
we shouldn't change the autocommit
+ state of a connection at initializing by the
ConnectionFactory. The autocommit state should
+ only be changed by the ConnectionManager. We have to
separate this stuff.
+ */
+ if (!jcd.getAttribute(INITIALIZATION_CHECK_AUTOCOMMIT,
FALSE_STR).equalsIgnoreCase(FALSE_STR)
+ && !conn.getAutoCommit())
+ {
+ conn.setAutoCommit(true);
+ }
}
catch (SQLException e)
{
@@ -287,6 +300,11 @@
return false;
}
+ public String createSequenceQuery(String sequenceName, Properties prop)
+ {
+ return createSequenceQuery(sequenceName);
+ }
+
/**
* Override this method to enable database based sequence generation
*/
@@ -388,7 +406,7 @@
{
if (i > 0)
{
- buf.append(" " + concatChar + " ");
+ buf.append(" ").append(concatChar).append(" ");
}
buf.append(theColumns[i]);
}
@@ -441,22 +459,14 @@
* answer true if the string starts with OJB_QUOTE_BEGIN_CHAR
* and ends with the OJB_QUOTE_END_CHAR
* @param aString
- * @return
*/
private static boolean isQuoted(String aString)
{
- if (aString != null &&
- aString.charAt(0) == OJB_QUOTE_BEGIN_CHAR &&
- aString.charAt(aString.length() - 1) == OJB_QUOTE_END_CHAR)
- {
- return true;
- }
- else
- {
- return false;
- }
+ return aString != null &&
+ aString.charAt(0) == OJB_QUOTE_BEGIN_CHAR &&
+ aString.charAt(aString.length() - 1) == OJB_QUOTE_END_CHAR;
}
-
+
/**
* Remove the OJB-Quotes from the String.
* @param aString
@@ -474,14 +484,6 @@
}
/**
- * @see
org.apache.ojb.broker.platforms.Platform#isCallableStatement(java.sql.PreparedStatement)
- */
- public boolean isCallableStatement(PreparedStatement stmt)
- {
- return stmt instanceof CallableStatement;
- }
-
- /**
* @see
org.apache.ojb.broker.platforms.Platform#registerOutResultSet(java.sql.CallableStatement,
int)
*/
public void registerOutResultSet(CallableStatement stmt, int position)
1.10 +2 -2
db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformFactory.java
Index: PlatformFactory.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- PlatformFactory.java 11 Mar 2005 19:50:03 -0000 1.9
+++ PlatformFactory.java 27 Aug 2005 12:23:42 -0000 1.10
@@ -45,7 +45,7 @@
public Platform getPlatformFor(JdbcConnectionDescriptor jcd)
{
String dbms = jcd.getDbms();
- Platform result = null;
+ Platform result;
String platformName = null;
result = (Platform) getPlatforms().get(dbms);
1.10 +115 -13
db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformHsqldbImpl.java
Index: PlatformHsqldbImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformHsqldbImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- PlatformHsqldbImpl.java 6 Apr 2005 14:45:42 -0000 1.9
+++ PlatformHsqldbImpl.java 27 Aug 2005 12:23:42 -0000 1.10
@@ -15,12 +15,94 @@
* limitations under the License.
*/
-import java.sql.PreparedStatement;
+import java.util.Properties;
+
+import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
/**
* This class extends <code>PlatformDefaultImpl</code> and defines specific
* behavior for the Hsqldb platform.
*
+ * <p>
+ * Supported properties on sequence creation:
+ * </p>
+ *
+ * <table cellspacing="2" cellpadding="2" border="3" frame="box">
+ * <tr>
+ * <td><strong>Property Key</strong></td>
+ * <td><strong>Property Values</strong></td>
+ * </tr>
+ * <tr>
+ * <td>seq.as</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the datatype used for the sequence.
+ * Allowed: <em>INTEGER</em> or <em>BIGINT</em>.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.start</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the first sequence number to be
+ * generated. Allowed: <em>1</em> or greater.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.incrementBy</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the interval between sequence numbers.
+ * This value can be any positive or negative
+ * integer, but it cannot be 0.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.maxValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set max value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.minValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set min value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cycle</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If <em>true</em>, specifies that the sequence continues to
generate
+ * values after reaching either its maximum or minimum value.
+ * <br/>
+ * If <em>false</em>, specifies that the sequence cannot generate
more values after
+ * reaching its maximum or minimum value.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cache</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies how many values of the sequence Oracle
+ * preallocates and keeps in memory for faster access.
+ * Allowed values: <em>2</em> or greater. If set <em>0</em>,
+ * an explicite <em>nocache</em> expression will be set.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.order</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If set <em>true</em>, guarantees that sequence numbers
+ * are generated in order of request.
+ * <br/>
+ * If <em>false</em>, a <em>no order</em> expression will be set.
+ * </td>
+ * </tr>
+ * </table>
* @author <a href="mailto:[EMAIL PROTECTED]">Thomas Mahler<a>
* @version $Id$
*/
@@ -68,6 +150,37 @@
return true;
}
+ public String createSequenceQuery(String sequenceName, Properties prop)
+ {
+ // CREATE SEQUENCE <sequencename> [AS {INTEGER | BIGINT}]
+ // [START WITH <startvalue>] [INCREMENT BY <incrementvalue>];
+ StringBuffer query = new
StringBuffer(createSequenceQuery(sequenceName));
+ if(prop != null)
+ {
+ Long value;
+ String str;
+
+ str = SequenceManagerHelper.getSeqAsValue(prop);
+ if(str != null)
+ {
+ query.append(" AS ").append(str);
+ }
+
+ value = SequenceManagerHelper.getSeqStart(prop);
+ if(value != null)
+ {
+ query.append(" START WITH ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqIncrementBy(prop);
+ if(value != null)
+ {
+ query.append(" INCREMENT BY ").append(value.longValue());
+ }
+ }
+ return query.toString();
+ }
+
/**
* @see
org.apache.ojb.broker.platforms.Platform#createSequenceQuery(java.lang.String)
*/
@@ -91,15 +204,4 @@
{
return "DROP SEQUENCE " + sequenceName;
}
-
- /**
- * HSQLDB does not implement CallableStatement.
- *
- * @see
org.apache.ojb.broker.platforms.Platform#isCallableStatement(java.sql.PreparedStatement)
- */
- public boolean isCallableStatement(PreparedStatement stmt)
- {
- return false;
- }
-
}
1.25 +162 -9
db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java
Index: PlatformOracleImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- PlatformOracleImpl.java 6 Apr 2005 14:45:42 -0000 1.24
+++ PlatformOracleImpl.java 27 Aug 2005 12:23:42 -0000 1.25
@@ -29,16 +29,98 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
+import java.util.Properties;
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;
import org.apache.ojb.broker.util.ClassHelper;
+import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
/**
* This class is a concrete implementation of <code>Platform</code>.
Provides an implementation
* that works around some issues with Oracle in general and Oracle's Thin
driver in particular.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Thomas Mahler</a>
+ * <p/>
+ * Many of the database sequence specific properties can be specified using
+ * <em>custom attributes</em> within the <em>sequence-manager</em> element.
+ * <br/>
+ * The database sequence specific properties are generally speaking, see
database user guide
+ * for detailed description.
+ *
+ * <p>
+ * Supported properties on sequence creation:
+ * </p>
+ *
+ * <table cellspacing="2" cellpadding="2" border="3" frame="box">
+ * <tr>
+ * <td><strong>Property Key</strong></td>
+ * <td><strong>Property Values</strong></td>
+ * </tr>
+ * <tr>
+ * <td>seq.start</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the first sequence number to be
+ * generated. Allowed: <em>1</em> or greater.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.incrementBy</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the interval between sequence numbers.
+ * This value can be any positive or negative
+ * integer, but it cannot be 0.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.maxValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set max value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.minValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set min value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cycle</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If <em>true</em>, specifies that the sequence continues to
generate
+ * values after reaching either its maximum or minimum value.
+ * <br/>
+ * If <em>false</em>, specifies that the sequence cannot generate
more values after
+ * reaching its maximum or minimum value.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cache</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies how many values of the sequence Oracle
+ * preallocates and keeps in memory for faster access.
+ * Allowed values: <em>2</em> or greater. If set <em>0</em>,
+ * an explicite <em>nocache</em> expression will be set.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.order</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If set <em>true</em>, guarantees that sequence numbers
+ * are generated in order of request.
+ * <br/>
+ * If <em>false</em>, a <em>no order</em> expression will be set.
+ * </td>
+ * </tr>
+ * </table>
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Thomas Mahler <a>
* @author <a href="mailto:[EMAIL PROTECTED]">Martin Kalén</a>
* @version $Id$
*/
@@ -68,6 +150,8 @@
private Logger logger =
LoggerFactory.getLogger(PlatformOracleImpl.class);
+ private Boolean usingOracleOCIDriver;
+
/**
* Default constructor.
*/
@@ -97,7 +181,7 @@
throw new PlatformException(e);
}
}
-
+
/**
* In Oracle we set escape processing explizit 'true' after a statement
was created.
*/
@@ -166,8 +250,8 @@
}
else if (sqlType == Types.CLOB && (value instanceof String || value
instanceof byte[]))
{
- Reader reader = null;
- int length = 0;
+ Reader reader;
+ int length;
if (value instanceof String)
{
String stringValue = (String) value;
@@ -250,7 +334,72 @@
public String createSequenceQuery(String sequenceName)
{
- return "create sequence " + sequenceName;
+ return "CREATE SEQUENCE " + sequenceName;
+ }
+
+ public String createSequenceQuery(String sequenceName, Properties prop)
+ {
+ /*
+ CREATE SEQUENCE [schema.]sequence
+ [INCREMENT BY integer]
+ [START WITH integer]
+ [MAXVALUE integer | NOMAXVALUE]
+ [MINVALUE integer | NOMINVALUE]
+ [CYCLE | NOCYCLE]
+ [CACHE integer | NOCACHE]
+ [ORDER | NOORDER]
+ */
+ StringBuffer query = new
StringBuffer(createSequenceQuery(sequenceName));
+ if(prop != null)
+ {
+ Boolean b;
+ Long value;
+
+ value = SequenceManagerHelper.getSeqIncrementBy(prop);
+ if(value != null)
+ {
+ query.append(" INCREMENT BY ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqStart(prop);
+ if(value != null)
+ {
+ query.append(" START WITH ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqMaxValue(prop);
+ if(value != null)
+ {
+ query.append(" MAXVALUE ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqMinValue(prop);
+ if(value != null)
+ {
+ query.append(" MINVALUE ").append(value.longValue());
+ }
+
+ b = SequenceManagerHelper.getSeqCycleValue(prop);
+ if(b != null)
+ {
+ if(b.booleanValue()) query.append(" CYCLE");
+ else query.append(" NOCYCLE");
+ }
+
+ value = SequenceManagerHelper.getSeqCacheValue(prop);
+ if(value != null)
+ {
+ query.append(" CACHE ").append(value.longValue());
+ }
+
+ b = SequenceManagerHelper.getSeqOrderValue(prop);
+ if(b != null)
+ {
+ if(b.booleanValue()) query.append(" ORDER");
+ else query.append(" NOORDER");
+ }
+ }
+ return query.toString();
}
public String nextSequenceQuery(String sequenceName)
@@ -308,10 +457,14 @@
* @return <code>true</code> if the connection is using Oracle OCI
driver,
* <code>false</code> otherwise.
*/
- protected static boolean isUsingOracleOCIDriver(Connection conn)
+ protected boolean isUsingOracleOCIDriver(Connection conn)
{
- final String dbUrl = getDbUrl(conn);
- return dbUrl != null && dbUrl.startsWith(OCI_URL_PREFIX);
+ if(usingOracleOCIDriver == null)
+ {
+ final String dbUrl = getDbUrl(conn);
+ usingOracleOCIDriver = (dbUrl != null &&
dbUrl.startsWith(OCI_URL_PREFIX)) ? Boolean.TRUE : Boolean.FALSE;
+ }
+ return usingOracleOCIDriver.booleanValue();
}
/**
1.11 +136 -2
db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformPostgreSQLImpl.java
Index: PlatformPostgreSQLImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformPostgreSQLImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- PlatformPostgreSQLImpl.java 25 Jun 2004 13:11:35 -0000 1.10
+++ PlatformPostgreSQLImpl.java 27 Aug 2005 12:23:42 -0000 1.11
@@ -18,13 +18,95 @@
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
+import java.util.Properties;
import org.apache.ojb.broker.query.LikeCriteria;
+import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
/**
* This class extends <code>PlatformDefaultImpl</code> and defines specific
* behavior for the PostgreSQL platform.
*
+ * <p/>
+ * Many of the database sequence specific properties can be specified using
+ * <em>custom attributes</em> within the <em>sequence-manager</em> element.
+ * <br/>
+ * The database sequence specific properties are generally speaking, see
database user guide
+ * for detailed description.
+ *
+ * <p>
+ * Supported properties on sequence creation:
+ * </p>
+ *
+ * <table cellspacing="2" cellpadding="2" border="3" frame="box">
+ * <tr>
+ * <td><strong>Property Key</strong></td>
+ * <td><strong>Property Values</strong></td>
+ * </tr>
+ * <tr>
+ * <td>seq.start</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the first sequence number to be
+ * generated. Allowed: <em>1</em> or greater.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.incrementBy</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the interval between sequence numbers.
+ * This value can be any positive or negative
+ * integer, but it cannot be 0.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.maxValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set max value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.minValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set min value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cycle</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If <em>true</em>, specifies that the sequence continues to
generate
+ * values after reaching either its maximum or minimum value.
+ * <br/>
+ * If <em>false</em>, specifies that the sequence cannot generate
more values after
+ * reaching its maximum or minimum value.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cache</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies how many values of the sequence Oracle
+ * preallocates and keeps in memory for faster access.
+ * Allowed values: <em>2</em> or greater. If set <em>0</em>,
+ * an explicite <em>nocache</em> expression will be set.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.order</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If set <em>true</em>, guarantees that sequence numbers
+ * are generated in order of request.
+ * <br/>
+ * If <em>false</em>, a <em>no order</em> expression will be set.
+ * </td>
+ * </tr>
+ * </table>
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Thomas Mahler<a>
* @version $Id$
*/
@@ -45,7 +127,59 @@
public String createSequenceQuery(String sequenceName)
{
- return "create sequence " + sequenceName;
+ return "CREATE SEQUENCE " + sequenceName;
+ }
+
+ public String createSequenceQuery(String sequenceName, Properties prop)
+ {
+ /*
+ CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname [ INCREMENT increment ]
+ [ MINVALUE minvalue ] [ MAXVALUE maxvalue ]
+ [ START start ] [ CACHE cache ] [ CYCLE ]
+ */
+ StringBuffer query = new
StringBuffer(createSequenceQuery(sequenceName));
+ if(prop != null)
+ {
+ Boolean b;
+ Long value;
+
+ value = SequenceManagerHelper.getSeqIncrementBy(prop);
+ if(value != null)
+ {
+ query.append(" INCREMENT ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqMinValue(prop);
+ if(value != null)
+ {
+ query.append(" MINVALUE ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqMaxValue(prop);
+ if(value != null)
+ {
+ query.append(" MAXVALUE ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqStart(prop);
+ if(value != null)
+ {
+ query.append(" START ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqCacheValue(prop);
+ if(value != null)
+ {
+ query.append(" CACHE ").append(value.longValue());
+ }
+
+ b = SequenceManagerHelper.getSeqCycleValue(prop);
+ if(b != null)
+ {
+ if(b.booleanValue()) query.append(" CYCLE");
+ }
+ }
+ return query.toString();
}
public String nextSequenceQuery(String sequenceName)
1.11 +153 -3
db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformSapdbImpl.java
Index: PlatformSapdbImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformSapdbImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- PlatformSapdbImpl.java 4 Apr 2004 23:53:35 -0000 1.10
+++ PlatformSapdbImpl.java 27 Aug 2005 12:23:42 -0000 1.11
@@ -18,9 +18,93 @@
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
+import java.util.Properties;
+
+import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
/**
* SapDB specific Platform implementation
+ *
+ * <p/>
+ * Many of the database sequence specific properties can be specified using
+ * <em>custom attributes</em> within the <em>sequence-manager</em> element.
+ * <br/>
+ * The database sequence specific properties are generally speaking, see
database user guide
+ * for detailed description.
+ *
+ * <p>
+ * Supported properties on sequence creation:
+ * </p>
+ *
+ * <table cellspacing="2" cellpadding="2" border="3" frame="box">
+ * <tr>
+ * <td><strong>Property Key</strong></td>
+ * <td><strong>Property Values</strong></td>
+ * </tr>
+ * <tr>
+ * <td>seq.start</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the first sequence number to be
+ * generated. Allowed: <em>1</em> or greater.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.incrementBy</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the interval between sequence numbers.
+ * This value can be any positive or negative
+ * integer, but it cannot be 0.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.maxValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set max value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.minValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set min value for sequence numbers.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cycle</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If <em>true</em>, specifies that the sequence continues to
generate
+ * values after reaching either its maximum or minimum value.
+ * <br/>
+ * If <em>false</em>, specifies that the sequence cannot generate
more values after
+ * reaching its maximum or minimum value.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.cache</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies how many values of the sequence Oracle
+ * preallocates and keeps in memory for faster access.
+ * Allowed values: <em>2</em> or greater. If set <em>0</em>,
+ * an explicite <em>nocache</em> expression will be set.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>seq.order</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If set <em>true</em>, guarantees that sequence numbers
+ * are generated in order of request.
+ * <br/>
+ * If <em>false</em>, a <em>no order</em> expression will be set.
+ * </td>
+ * </tr>
+ * </table>
+ *
* @author Justin A. Stanczak
* @author Matthew Baird (mattb
* @version $Id$
@@ -46,7 +130,8 @@
}
}
- /** Get join syntax type for this RDBMS - one on of the constants from
JoinSyntaxType interface
+ /**
+ * Get join syntax type for this RDBMS - one on of the constants from
JoinSyntaxType interface
*/
public byte getJoinSyntaxType()
{
@@ -65,7 +150,72 @@
public String createSequenceQuery(String sequenceName)
{
- return "create sequence " + sequenceName;
+ return "CREATE SEQUENCE " + sequenceName;
+ }
+
+ public String createSequenceQuery(String sequenceName, Properties prop)
+ {
+ /*
+ CREATE SEQUENCE [<schema_name>.]<sequence_name>
+ [INCREMENT BY <integer>]
+ [START WITH <integer>]
+ [MAXVALUE <integer> | NOMAXVALUE]
+ [MINVALUE <integer> | NOMINVALUE]
+ [CYCLE | NOCYCLE]
+ [CACHE <unsigned_integer> | NOCACHE]
+ [ORDER|NOORDER]
+ */
+ StringBuffer query = new
StringBuffer(createSequenceQuery(sequenceName));
+ if(prop != null)
+ {
+ Boolean b;
+ Long value;
+
+ value = SequenceManagerHelper.getSeqIncrementBy(prop);
+ if(value != null)
+ {
+ query.append(" INCREMENT BY ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqStart(prop);
+ if(value != null)
+ {
+ query.append(" START WITH ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqMaxValue(prop);
+ if(value != null)
+ {
+ query.append(" MAXVALUE ").append(value.longValue());
+ }
+
+ value = SequenceManagerHelper.getSeqMinValue(prop);
+ if(value != null)
+ {
+ query.append(" MINVALUE ").append(value.longValue());
+ }
+
+ b = SequenceManagerHelper.getSeqCycleValue(prop);
+ if(b != null)
+ {
+ if(b.booleanValue()) query.append(" CYCLE");
+ else query.append(" NOCYCLE");
+ }
+
+ value = SequenceManagerHelper.getSeqCacheValue(prop);
+ if(value != null)
+ {
+ query.append(" CACHE ").append(value.longValue());
+ }
+
+ b = SequenceManagerHelper.getSeqOrderValue(prop);
+ if(b != null)
+ {
+ if(b.booleanValue()) query.append(" ORDER");
+ else query.append(" NOORDER");
+ }
+ }
+ return query.toString();
}
public String nextSequenceQuery(String sequenceName)
1.4 +2 -2
db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformWLOracle9iImpl.java
Index: PlatformWLOracle9iImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformWLOracle9iImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PlatformWLOracle9iImpl.java 15 Mar 2005 02:50:45 -0000 1.3
+++ PlatformWLOracle9iImpl.java 27 Aug 2005 12:23:42 -0000 1.4
@@ -26,8 +26,8 @@
import java.util.WeakHashMap;
import org.apache.ojb.broker.metadata.JdbcType;
+import org.apache.ojb.broker.metadata.JdbcTypesHelper;
import org.apache.ojb.broker.util.ClassHelper;
-import org.apache.ojb.broker.util.JdbcTypesHelper;
/**
* This class is a concrete implementation of <code>Platform</code>. Provides
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]