Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 11208 invoked from network); 13 Jun 2006 19:11:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Jun 2006 19:11:24 -0000 Received: (qmail 2272 invoked by uid 500); 13 Jun 2006 19:11:23 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 2245 invoked by uid 500); 13 Jun 2006 19:11:23 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 2234 invoked by uid 500); 13 Jun 2006 19:11:23 -0000 Received: (qmail 2231 invoked by uid 99); 13 Jun 2006 19:11:22 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 12:11:22 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 12:11:22 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 352431A983A; Tue, 13 Jun 2006 12:11:02 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r413954 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker: accesslayer/JdbcAccessImpl.java platforms/PlatformDefaultImpl.java Date: Tue, 13 Jun 2006 19:11:01 -0000 To: ojb-commits@db.apache.org From: arminw@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060613191102.352431A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: arminw Date: Tue Jun 13 12:11:01 2006 New Revision: 413954 URL: http://svn.apache.org/viewvc?rev=413954&view=rev Log: check fields for active LOB content Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java?rev=413954&r1=413953&r2=413954&view=diff ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java Tue Jun 13 12:11:01 2006 @@ -28,6 +28,7 @@ import org.apache.ojb.broker.PersistenceBroker; import org.apache.ojb.broker.PersistenceBrokerException; import org.apache.ojb.broker.PersistenceBrokerSQLException; +import org.apache.ojb.broker.lob.LobHandle; import org.apache.ojb.broker.accesslayer.sql.SelectStatement; import org.apache.ojb.broker.core.ValueContainer; import org.apache.ojb.broker.metadata.ArgumentDescriptor; @@ -498,7 +499,23 @@ { // workaround for issue with optimistic locking with enabled batch mode boolean batchSetting = preHandleBatchProcess(cld); + + // we can only update LOB content when it's associated with current tx + if(cld.hasLobField()) + { + FieldDescriptor[] fields = cld.getLobFields(); + for(int i = 0; i < fields.length; i++) + { + FieldDescriptor field = fields[i]; + Object o = field.getPersistentField().get(obj); + if(o instanceof LobHandle) + { + ((LobHandle) o).checkActive(); + } + } + } stmt = sm.getUpdateStatement(cld); + if (stmt == null) { logger.error("getUpdateStatement returned a null statement"); Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java?rev=413954&r1=413953&r2=413954&view=diff ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java Tue Jun 13 12:11:01 2006 @@ -32,6 +32,7 @@ import org.apache.ojb.broker.accesslayer.JoinSyntaxTypes; import org.apache.ojb.broker.lob.BlobHandle; import org.apache.ojb.broker.lob.ClobHandle; +import org.apache.ojb.broker.lob.LobHandle; import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor; import org.apache.ojb.broker.query.LikeCriteria; import org.apache.ojb.broker.util.SqlHelper; @@ -319,19 +320,32 @@ /* we use method advised by JDBC 3.0 specification (see 16.3.2) */ - if(value instanceof BlobHandle && ((BlobHandle) value).isTransient()) + if(value instanceof LobHandle) { - int length = (int) b.length(); - if(b.length() < 0) + LobHandle handle = (LobHandle) value; + // found new LOB object value + if(handle.isTransient()) { - /* - We need the length of the specified stream to use #setBinaryStream - This workaround seems to work for many DB (hsql, mysql, maxdb), the - stream is read till EOF without throwing an exception - */ - length = Integer.MAX_VALUE; + int length = (int) b.length(); + if(b.length() < 0) + { + /* + We need the length of the specified stream to use #setBinaryStream + This workaround seems to work for many DB (hsql, mysql, maxdb), the + stream is read till EOF without throwing an exception + */ + length = Integer.MAX_VALUE; + } + ps.setBinaryStream(index, b.getBinaryStream(), length); + } + else + { + if(detectLocatorsUpdateState(ps)) + { + handle.checkActive(); + ps.setBlob(index, b); + } } - ps.setBinaryStream(index, b.getBinaryStream(), length); } else if(detectLocatorsUpdateState(ps)) { @@ -365,19 +379,32 @@ /* we use method advised by JDBC 3.0 specification (see 16.3.2) */ - if(value instanceof ClobHandle && ((ClobHandle) value).isTransient()) + if(value instanceof LobHandle) { - int length = (int) c.length(); - if(c.length() < 0) + LobHandle handle = (LobHandle) value; + // found new LOB object value + if(handle.isTransient()) { - /* - We need the length of the specified stream to use #setCharacterStream - This workaround seems to work for many DB (hsql, mysql, maxdb), the - reader is read till EOF without throwing an exception - */ - length = Integer.MAX_VALUE; + int length = (int) c.length(); + if(c.length() < 0) + { + /* + We need the length of the specified stream to use #setCharacterStream + This workaround seems to work for many DB (hsql, mysql, maxdb), the + reader is read till EOF without throwing an exception + */ + length = Integer.MAX_VALUE; + } + ps.setCharacterStream(index, c.getCharacterStream(), length); + } + else + { + if(detectLocatorsUpdateState(ps)) + { + handle.checkActive(); + ps.setClob(index, c); + } } - ps.setCharacterStream(index, c.getCharacterStream(), length); } else if(detectLocatorsUpdateState(ps)) { --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org