You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2005/01/13 16:50:06 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer StatementsForClassImpl.java
arminw 2005/01/13 07:50:06
Modified: src/java/org/apache/ojb/broker/accesslayer Tag:
OJB_1_0_RELEASE StatementsForClassImpl.java
Log:
fix by Vadim Gritsenko:
This patch fixes incorrect test in StatementsForClassImpl. Currently for
create/update/delete procedures it has single check, in usePreparedStatement:
return !((classDescriptor.getUpdateProcedure() != null) &&(classDescriptor.getUpdateProcedure().hasReturnValues()));
Which means that if update procedure is present, it will attempt to call a
procedure for create/delete as well - even if none is configured.
Revision Changes Path
No revision
No revision
1.22.2.1 +33 -11 db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java
Index: StatementsForClassImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java,v
retrieving revision 1.22
retrieving revision 1.22.2.1
diff -u -r1.22 -r1.22.2.1
--- StatementsForClassImpl.java 9 Apr 2004 13:22:29 -0000 1.22
+++ StatementsForClassImpl.java 13 Jan 2005 15:50:05 -0000 1.22.2.1
@@ -91,13 +91,13 @@
/**
* Answer true if a PreparedStatement has to be used
- * <br>false for a CallableStatement
+ * <br>false for a CallableStatement
* @return
*/
- protected boolean usePreparedStatement()
+ protected boolean usePreparedDeleteStatement()
{
- return !((classDescriptor.getUpdateProcedure() != null) &&
- (classDescriptor.getUpdateProcedure().hasReturnValues()));
+ return !(classDescriptor.getDeleteProcedure() != null &&
+ classDescriptor.getDeleteProcedure().hasReturnValues());
}
public PreparedStatement getDeleteStmt(Connection con) throws SQLException
@@ -112,7 +112,7 @@
con,
deleteSql,
Query.NOT_SCROLLABLE,
- usePreparedStatement());
+ usePreparedDeleteStatement());
}
catch (SQLException ex)
{
@@ -137,6 +137,17 @@
return stmt;
}
+ /**
+ * Answer true if a PreparedStatement has to be used
+ * <br>false for a CallableStatement
+ * @return
+ */
+ protected boolean usePreparedInsertStatement()
+ {
+ return !(classDescriptor.getInsertProcedure() != null &&
+ classDescriptor.getInsertProcedure().hasReturnValues());
+ }
+
public PreparedStatement getInsertStmt(Connection con) throws SQLException
{
if (insertSql == null)
@@ -149,7 +160,7 @@
con,
insertSql,
Query.NOT_SCROLLABLE,
- usePreparedStatement());
+ usePreparedInsertStatement());
}
catch (SQLException ex)
{
@@ -191,6 +202,17 @@
}
}
+ /**
+ * Answer true if a PreparedStatement has to be used
+ * <br>false for a CallableStatement
+ * @return
+ */
+ protected boolean usePreparedUpdateStatement()
+ {
+ return !(classDescriptor.getUpdateProcedure() != null &&
+ classDescriptor.getUpdateProcedure().hasReturnValues());
+ }
+
public PreparedStatement getUpdateStmt(Connection con) throws SQLException
{
if (updateSql == null)
@@ -203,7 +225,7 @@
con,
updateSql,
Query.NOT_SCROLLABLE,
- usePreparedStatement());
+ usePreparedUpdateStatement());
}
catch (SQLException ex)
{
@@ -225,14 +247,14 @@
/**
* prepares a statement with parameters that should work with most RDBMS
- *
+ *
* @param con the connection to utilize
* @param sql the sql syntax to use when creating the statement.
* @param scrollable determines if the statement will be scrollable.
* @param createPreparedStatement if <code>true</code>, then a
* {@link PreparedStatement} will be created. if <code>false</code>, then
- * a {@link CallableStatement} will be created.
- *
+ * a {@link java.sql.CallableStatement} will be created.
+ *
* @return a statement that can be used to execute the syntax contained in
* the <code>sql</code> argument.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org