You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Farrukh Najmi <Fa...@Sun.COM> on 2006/06/06 13:56:09 UTC

A truncation error was encountered tryin,g to shrink BLOB 'XX-RESOLVE-XX' to length 1048576.

Dear Derby team,

I am storing a blob into Derby 10.1.2.1 using hibernate and getting this 
SQLException from Derby (see second stack trace below).
The blob is just a gig image of size 1.4MB. This seems well within the 
2GB limit for blobs. What is wrong and how can I fix it?
Thanks for your help.

2006-06-06 07:22:37,191 ERROR 
org.freebxml.omar.server.repository.hibernate.HibernateRepositoryManager[http-8443-Processor25] 
- Failed to insert RepositoryItem 
urn:uuid:a552cac2-cab0-4042-b973-f1568c1d4bfd.
net.sf.hibernate.JDBCException: could not insert: 
[org.freebxml.omar.server.repository.hibernate.RepositoryItemBean#RepositoryItemKey: 
lid=urn:uuid:a552cac2-cab0-4042-b973-f1568c
1d4bfd versionName=1.1]
        at 
net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:478)
        at 
net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
        at 
net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
        at 
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
        at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
        at 
net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
        at 
org.freebxml.omar.server.repository.hibernate.HibernateRepositoryManager.insert(HibernateRepositoryManager.java:202)

....

Caused by: SQL Exception: A truncation error was encountered trying to 
shrink BLOB 'XX-RE
SOLVE-XX' to length 1048576.
        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java)
        at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java)
        at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java)
        at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java)
        at 
org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
        at 
org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
        at 
net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
        at 
net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
        ... 60 more

-- 
Regards,
Farrukh



Re: A truncation error was encountered tryin,g to shrink BLOB 'XX-RESOLVE-XX' to length 1048576.

Posted by Farrukh Najmi <Fa...@Sun.COM>.
Farrukh Najmi wrote:
>
> Dear Derby team,
>
> I am storing a blob into Derby 10.1.2.1 using hibernate 

In case it is helpful, here is the source code in stack trace below that 
uses hibernate to insert the blob:

http://ebxmlrr.cvs.sourceforge.net/ebxmlrr/omar/src/java/org/freebxml/omar/server/repository/hibernate/HibernateRepositoryManager.java?view=log

Thanks.
> and getting this SQLException from Derby (see second stack trace below).
> The blob is just a gig image of size 1.4MB. This seems well within the 
> 2GB limit for blobs. What is wrong and how can I fix it?
> Thanks for your help.
>
> 2006-06-06 07:22:37,191 ERROR 
> org.freebxml.omar.server.repository.hibernate.HibernateRepositoryManager[http-8443-Processor25] 
> - Failed to insert RepositoryItem 
> urn:uuid:a552cac2-cab0-4042-b973-f1568c1d4bfd.
> net.sf.hibernate.JDBCException: could not insert: 
> [org.freebxml.omar.server.repository.hibernate.RepositoryItemBean#RepositoryItemKey: 
> lid=urn:uuid:a552cac2-cab0-4042-b973-f1568c
> 1d4bfd versionName=1.1]
>        at 
> net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:478) 
>
>        at 
> net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442) 
>
>        at 
> net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29) 
>
>        at 
> net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
>        at 
> net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
>        at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
>        at 
> net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61) 
>
>        at 
> org.freebxml.omar.server.repository.hibernate.HibernateRepositoryManager.insert(HibernateRepositoryManager.java:202) 
>
>
> ....
>
> Caused by: SQL Exception: A truncation error was encountered trying to 
> shrink BLOB 'XX-RE
> SOLVE-XX' to length 1048576.
>        at 
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java)
>        at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java) 
>
>        at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java) 
>
>        at 
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java) 
>
>        at 
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java) 
>
>        at 
> org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java) 
>
>        at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java) 
>
>        at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java) 
>
>        at 
> org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101) 
>
>        at 
> org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101) 
>
>        at 
> net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22) 
>
>        at 
> net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468) 
>
>        ... 60 more
>


-- 
Regards,
Farrukh



Re: A truncation error was encountered tryin,g to shrink BLOB 'XX-RESOLVE-XX' to length 1048576.

Posted by Farrukh Najmi <Fa...@Sun.COM>.
Bernt M. Johnsen wrote:

>>> Thank you Dan! That sounds like the problem.
>>> BTW I am curious why the 2G is not the default?
>>> Is there a performance / space downside to specifying BLOB(2G) always?
>>>       
>> It's due to Derby's history. BLOB/CLOB datatypes were added while
>> Cloudscape was closed-sourced at IBM and thus matched DB2 in behaviour.
>>
>> There are no space concerns, no pre-allocation of space. The length only
>> specifies the largest possible BLOB/CLOB value for that column.
>>     
>
> Then, a largest possible default (2G?) would be a user-friendly
> improvement to Derby.
>
>   
+1

My project had to jump thru hoops to cope with this out because we use 
hibernate 2.1 which uses a GenericDialect for Derby
that did not support setting length of blob type. We had to use 
hibernate extension features to create a DerbyDialect that handled this.

So yes, please *do* change the default to 2GB or whatever is the max if 
there is no performance and size penalty.

-- 
Regards,
Farrukh



Re: A truncation error was encountered tryin,g to shrink BLOB 'XX-RESOLVE-XX' to length 1048576.

Posted by "Bernt M. Johnsen" <Be...@Sun.COM>.
>>>>>>>>>>>> Daniel John Debrunner wrote (2006-06-06 14:39:56):
> Farrukh Najmi wrote:
> 
> > Daniel John Debrunner wrote:
> 
> >> You probably created the table without specifying a length on BLOB, this
> >> defaults to BLOB(1M). You need to use BLOB(2G). e.g.
> >>
> >> create table T (a int, b BLOB(2G))
> >>
> >> A bug about this info missing in the doc was reported as DERBY-769
> >>
> >> http://issues.apache.org/jira/browse/DERBY-769
> 
> > Thank you Dan! That sounds like the problem.
> > BTW I am curious why the 2G is not the default?
> > Is there a performance / space downside to specifying BLOB(2G) always?
> 
> It's due to Derby's history. BLOB/CLOB datatypes were added while
> Cloudscape was closed-sourced at IBM and thus matched DB2 in behaviour.
> 
> There are no space concerns, no pre-allocation of space. The length only
> specifies the largest possible BLOB/CLOB value for that column.

Then, a largest possible default (2G?) would be a user-friendly
improvement to Derby.

-- 
Bernt Marius Johnsen, Database Technology Group, 
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway

Re: A truncation error was encountered tryin,g to shrink BLOB 'XX-RESOLVE-XX' to length 1048576.

Posted by Daniel John Debrunner <dj...@apache.org>.
Farrukh Najmi wrote:

> Daniel John Debrunner wrote:

>> You probably created the table without specifying a length on BLOB, this
>> defaults to BLOB(1M). You need to use BLOB(2G). e.g.
>>
>> create table T (a int, b BLOB(2G))
>>
>> A bug about this info missing in the doc was reported as DERBY-769
>>
>> http://issues.apache.org/jira/browse/DERBY-769

> Thank you Dan! That sounds like the problem.
> BTW I am curious why the 2G is not the default?
> Is there a performance / space downside to specifying BLOB(2G) always?

It's due to Derby's history. BLOB/CLOB datatypes were added while
Cloudscape was closed-sourced at IBM and thus matched DB2 in behaviour.

There are no space concerns, no pre-allocation of space. The length only
specifies the largest possible BLOB/CLOB value for that column.

Dan.



Re: A truncation error was encountered tryin,g to shrink BLOB 'XX-RESOLVE-XX' to length 1048576.

Posted by Farrukh Najmi <Fa...@Sun.COM>.
Daniel John Debrunner wrote:
> Farrukh Najmi wrote:
>
>   
>> Dear Derby team,
>>
>> I am storing a blob into Derby 10.1.2.1 using hibernate and getting this
>> SQLException from Derby (see second stack trace below).
>> The blob is just a gig image of size 1.4MB. This seems well within the
>> 2GB limit for blobs. What is wrong and how can I fix it?
>>     
>
> You probably created the table without specifying a length on BLOB, this
> defaults to BLOB(1M). You need to use BLOB(2G). e.g.
>
> create table T (a int, b BLOB(2G))
>
> A bug about this info missing in the doc was reported as DERBY-769
>
> http://issues.apache.org/jira/browse/DERBY-769
>
> Dan.
>
>
>   
Thank you Dan! That sounds like the problem.
BTW I am curious why the 2G is not the default?
Is there a performance / space downside to specifying BLOB(2G) always?

-- 
Regards,
Farrukh



Re: A truncation error was encountered tryin,g to shrink BLOB 'XX-RESOLVE-XX' to length 1048576.

Posted by Daniel John Debrunner <dj...@apache.org>.
Farrukh Najmi wrote:

> 
> Dear Derby team,
> 
> I am storing a blob into Derby 10.1.2.1 using hibernate and getting this
> SQLException from Derby (see second stack trace below).
> The blob is just a gig image of size 1.4MB. This seems well within the
> 2GB limit for blobs. What is wrong and how can I fix it?

You probably created the table without specifying a length on BLOB, this
defaults to BLOB(1M). You need to use BLOB(2G). e.g.

create table T (a int, b BLOB(2G))

A bug about this info missing in the doc was reported as DERBY-769

http://issues.apache.org/jira/browse/DERBY-769

Dan.