One of the problems we discovered with Oracle LOB types while using them in a 2-tier 
environment was that the LOB lengths were being recorded incorrectly. (even when using 
the Oracle specific LOB classes) As long as the LOB grew in length, there was no 
problem. As soon as you wrote back a LOB that was shorter than the prior instance, 
errors occurred. The way we got around this was to create a PL/SQL block like this: 

begin DBMS_LOB.TRIM(?, ?);DBMS_LOB.TRIM(?, ?); end;

That would be executed within the same DB transaction that housed the update.

Karl Koster
[EMAIL PROTECTED]
Sempra Energy Trading

-----Original Message-----
From: Dain Sundstrom [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 18, 2002 11:05 AM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-dev] Oracle BLOB handling - FIXED?


This is the way the code was before I integrated the Oracle BLOB patch.
The problem is the serialized stream is being truncated to 4000 bytes.

I just got an email from someone willing to work on implementing correct 
BLOB handling.

I'd still like someone to try this in Oracle 8.

-dain

Stephen Coy wrote:
> I've done some more  poking at this, and modified JDBCUtil.setParameter 
> as follows:
> 
>       //
>       // Binary types need to be converted to a byte array and set
>       //
>       if(isBinaryJDBCType(jdbcType))
>       {
>          byte[] bytes = convertObjectToByteArray(value);
> 
>          if (bytes.length < 2000 && jdbcType != Types.BLOB)
>          {
>             // it's more efficient to use setBinaryStream for large
>             // streams, and causes problems if not done on some DBMS
>             // implementations
>             ps.setBytes(index, bytes);
>          } else
>          {
>             InputStream in = null;
>             try
>             {
>                in = new ByteArrayInputStream(bytes);
>                ps.setBinaryStream(index, in, bytes.length);
>             } finally
>             {
>                safeClose(in);
>             }
>          }
>          return;
> 
> ie. Forget about the ByteArrayBlob class.
> 
> This works fine when writing to the database.
> 
> However, reading the data back fails:
> 
> 2002-06-18 23:59:20,671 DEBUG 
> [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.SimpleEJB] 
> Executing SQL: SELECT booleanPrimitive, booleanObject, bytePrimitive, 
> byteObject, shortPrimitive, shortObject, integerPrimitive, 
> integerObject, longPrimitive, longObject, floatPrimitive, floatObject, 
> doublePrimitive, doubleObject, stringValue, utilDateValue, sqlDateValue, 
> timeValue, timestampValue, bigDecimalValue, byteArrayValue, objectValue 
> FROM SIMPLE WHERE (id=?)
> 2002-06-18 23:59:20,680 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.id] 
> Set parameter: index=1, jdbcType=VARCHAR, value=simple
> 2002-06-18 23:59:20,707 TRACE 
> 
>[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.booleanPrimitive]
> 
> 
>  Get result: index=1, javaType=boolean, Simple, value=true
> 2002-06-18 23:59:20,709 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.booleanObject] 
> 
>  Get result: index=2, javaType=java.lang.Boolean, Simple, value=false
> 2002-06-18 23:59:20,713 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.bytePrimitive] 
> 
>  Get result: index=3, javaType=byte, Simple, value=11
> 2002-06-18 23:59:20,715 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.byteObject] 
> 
>  Get result: index=4, javaType=java.lang.Byte, Simple, value=22
> 2002-06-18 23:59:20,717 TRACE 
> 
>[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.shortPrimitive] 
> 
>  Get result: index=5, javaType=short, Simple, value=33
> 2002-06-18 23:59:20,718 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.shortObject] 
> 
>  Get result: index=6, javaType=java.lang.Short, Simple, value=44
> 2002-06-18 23:59:20,720 TRACE 
> 
>[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.integerPrimitive]
> 
> 
>  Get result: index=7, javaType=int, Simple, value=55
> 2002-06-18 23:59:20,726 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.integerObject] 
> 
>  Get result: index=8, javaType=java.lang.Integer, Simple, value=66
> 2002-06-18 23:59:20,728 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.longPrimitive] 
> 
>  Get result: index=9, javaType=long, Simple, value=77
> 2002-06-18 23:59:20,730 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.longObject] 
> 
>  Get result: index=10, javaType=java.lang.Long, Simple, value=88
> 2002-06-18 23:59:20,731 TRACE 
> 
>[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.floatPrimitive] 
> 
>  Get result: index=11, javaType=float, Simple, value=11.11
> 2002-06-18 23:59:20,733 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.floatObject] 
> 
>  Get result: index=12, javaType=java.lang.Float, Simple, value=22.22
> 2002-06-18 23:59:20,735 TRACE 
> 
>[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.doublePrimitive]
> 
> 
>  Get result: index=13, javaType=double, Simple, value=33.33
> 2002-06-18 23:59:20,738 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.doubleObject] 
> 
>  Get result: index=14, javaType=java.lang.Double, Simple, value=44.44
> 2002-06-18 23:59:20,740 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.stringValue] 
> 
>  Get result: index=15, javaType=java.lang.String, Simple, value=test 
> string value
> 2002-06-18 23:59:20,742 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.utilDateValue] 
> 
>  Get result: index=16, javaType=java.util.Date, Simple, value=1970-01-01 
> 11:00:01.111
> 2002-06-18 23:59:20,744 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.sqlDateValue] 
> 
>  Get result: index=17, javaType=java.sql.Date, Simple, value=1981-05-05
> 2002-06-18 23:59:20,746 TRACE 
> [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.timeValue] 
> 
>  Get result: index=18, javaType=java.sql.Time, Simple, value=22:33:44
> 2002-06-18 23:59:20,748 TRACE 
> 
>[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.timestampValue] 
> 
>  Get result: index=19, javaType=java.sql.Timestamp, Simple, 
> value=1970-01-01 11:00:04.444
> 2002-06-18 23:59:20,749 TRACE 
> 
>[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.bigDecimalValue]
> 
> 
>  Get result: index=20, javaType=java.math.BigDecimal, Simple, 
> value=12345678
> 2002-06-18 23:59:20,751 TRACE 
> 
>[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.byteArrayValue] 
> 
>  Get result: index=21, javaType=[B, Simple, value=[B@2b8a17
> 2002-06-18 23:59:20,758 TRACE 
> [org.jboss.ejb.plugins.EntitySynchronizationInterceptor] loadEntity 
> Exception, clear tx for 
> ctx=org.jboss.ejb.EntityEnterpriseContext@74683e, 
> tx=TransactionImpl:XidImpl [FormatId=257, 
> GlobalId=edoras.resolvesw.com.au//40, BranchQual=]
> 2002-06-18 23:59:20,760 TRACE 
> [org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy] entryRemoved, 
> entry=key: null, object: null, entry: 67e62c
> 2002-06-18 23:59:20,762 TRACE 
> [org.jboss.ejb.plugins.EntityInstanceInterceptor] Ending invoke, 
> exceptionThrown, ctx=org.jboss.ejb.EntityEnterpriseContext@74683e
> 2002-06-18 23:59:20,764 TRACE 
> [org.jboss.ejb.plugins.EntityInstanceInterceptor] End invoke, 
> key=simple, ctx=org.jboss.ejb.EntityEnterpriseContext@74683e
> 2002-06-18 23:59:20,765 TRACE 
> [org.jboss.ejb.plugins.EntityLockInterceptor] End invoke, key=simple
> 2002-06-18 23:59:20,766 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] 
> TxInterceptorCMT: In finally
> 2002-06-18 23:59:20,770 ERROR [org.jboss.ejb.plugins.LogInterceptor] 
> TransactionRolledbackException, causedBy:
> java.sql.SQLException: Unable to load to deserialize result: 
> java.io.StreamCorruptedException: InputStream does not contain a 
> serialized object
>     at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.convertByteArrayToObject
> (JDBCUtil.java:599)
>     at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.getResult(JDBCUtil.java:306)
>     at 
> 
>org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadArgumentResults( 
> 
> JDBCAbstractCMPFieldBridge.java:350)
>     at 
> 
>org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadInstanceResults( 
> 
> JDBCAbstractCMPFieldBridge.java:304)
>     at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute
> (JDBCLoadEntityCommand.java:142)
>     at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute
> (JDBCLoadEntityCommand.java:62)
>     at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity
> (JDBCStoreManager.java:569)
>     at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity
> (CMPPersistenceManager.java:410)
>     at 
> org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity( 
> 
> CachedConnectionInterceptor.java:353)
>     at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke
> (EntitySynchronizationInterceptor.java:262)
>     at 
> org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke
> (CachedConnectionInterceptor.java:186)
>     at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke
> (EntityInstanceInterceptor.java:152)
>     at 
> org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java: 
> 
> 107)
>     at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke
> (EntityCreationInterceptor.java:69)
>     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext
> (AbstractTxInterceptor.java:96)
>     at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions
> (TxInterceptorCMT.java:176)
>     at 
> org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
>     at 
> org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:
> 129)
>     at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:183)
>     at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke
> (ProxyFactoryFinderInterceptor.java:156)
>     at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:482)
>     at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke
> (BaseLocalProxyFactory.java:304)
>     at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
>     at $Proxy41.getBooleanPrimitive(Unknown Source)
>     at org.jboss.test.cmp2.simple.SimpleUnitTestCase.testBooleanPrimitive
> (SimpleUnitTestCase.java:90)
>     at java.lang.reflect.Method.invoke(Native Method)
>     at junit.framework.TestCase.runTest(TestCase.java:166)
>     at junit.framework.TestCase.runBare(TestCase.java:140)
>     at net.sourceforge.junitejb.EJBTestCase.runBare(EJBTestCase.java:133)
>     at 
> net.sourceforge.junitejb.EJBTestRunnerBean.runTestCase(EJBTestRunnerBean.java: 
> 
> 102)
>     at 
> net.sourceforge.junitejb.EJBTestRunnerBean.run(EJBTestRunnerBean.java:44)
>     at java.lang.reflect.Method.invoke(Native Method)
>     at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke
> (StatelessSessionContainer.java:606)
>     at 
> org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke
> (CachedConnectionInterceptor.java:186)
>     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext
> (AbstractTxInterceptor.java:96)
>     at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext
> (AbstractTxInterceptorBMT.java:144)
>     at 
> org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
>     at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke
> (StatelessSessionInstanceInterceptor.java:77)
>     at 
> org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:
> 129)
>     at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:183)
>     at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke
> (ProxyFactoryFinderInterceptor.java:156)
>     at 
> org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java: 
> 
> 303)
>     at org.jboss.ejb.Container.invoke(Container.java:687)
>     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
>     at 
> org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:321)
>     at java.lang.reflect.Method.invoke(Native Method)
>     at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
>     at sun.rmi.transport.Transport$1.run(Transport.java:152)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
>     at 
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
>     at 
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:
> 706)
>     at java.lang.Thread.run(Thread.java:496)
> 2002-06-18 23:59:20,789 TRACE [org.jboss.ejb.plugins.LogInterceptor] End 
> method=getBooleanPrimitive
> 
> This seems to indicate that the BLOB was reloaded correctly, but the 
> OBJECT column was fubar.
> 
> A possible cause of this is that I don't think that you can use 
> ResultSet.getBytes to recover the data from a BLOB that was written with 
> PreparedStatement.setBinaryStream.
> 
> Unfortunately, it will be another day before I can pursue this further.
> 
> 
> 
> On Sunday, June 16, 2002, at 03:28  PM, Dain Sundstrom wrote:
> 
>> I just committed the code from patch [ 525663 ] CMP and oracle blobs. 
>> Can some with Oracle check if the code actually works?
>>
>> The following command will execute a new test I added which has a 
>> field of every type:
>>
>> ./build.sh -Dtest=org.jboss.test.cmp2.simple.SimpleUnitTestCase one-test
>>
>> You'll need to change the datasource and datasource-mapping in the
>> src/resources/cmp2/simple/META-INF/jbosscmp-jdbc.xml file.
>>
>> This won't work perfectly for every database vendor, because some 
>> vendor's don't support millisecond precise time and nanosecond precise 
>> timestamp values.  The test that is important for blobs is 
>> testObjectValue.
> 
> 
> 
> ---------------------------------------------------------------------------- 
> 
>                   Bringing you mounds of caffeinated joy
>                      >>>     http://thinkgeek.com/sf    <<<
> 
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development


-- 
xxxxxxxxxxxxxxxxxxxxxxxx
Dain Sundstrom
Chief Architect JBossCMP
JBoss Group, LLC
xxxxxxxxxxxxxxxxxxxxxxxx


----------------------------------------------------------------------------
                   Bringing you mounds of caffeinated joy
                      >>>     http://thinkgeek.com/sf    <<<

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development


**********************************************************************
This e-mail contains privileged attorney-client communications and/or confidential 
information, and is only for the use by the intended recipient. Receipt by an 
unintended recipient does not constitute a waiver of any applicable privilege.

Reading, disclosure, discussion, dissemination, distribution or copying of this 
information by anyone other than the intended recipient or his or her employees or 
agents is strictly prohibited.  If you have received this communication in error, 
please immediately notify us and delete the original material from your computer.

Sempra Energy Trading Corp. (SET) is not the same company as SDG&E or SoCalGas, the 
utilities owned by SET's parent company.  SET is not regulated by the California 
Public Utilities Commission and you do not have to buy SET's products and services to 
continue to receive quality regulated service from the utilities.
**********************************************************************


----------------------------------------------------------------------------
                   Bringing you mounds of caffeinated joy
                      >>>     http://thinkgeek.com/sf    <<<

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to