Skip to main content

@Lob

4 replies [Last post]
senderj
Offline
Joined: 2008-09-24

I am using gf 2.1, Toplink to MySQL. I have a collection Vplist in my entity bean VpPairList and use @Lob when declaring it. The schema is correctly created with the column as BLOB. My session bean creates the entity correctly and it works. But for some processing, the session bean hits an exception saying that the data is too long:

Internal Exception: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'VPLIST' at row 1
Error Code: 0
Call: INSERT INTO VPPAIRLIST (ID, VPLIST) VALUES (?, ?)
.....

I saw people discussing putting a binary file into a BLOB. So I expect there shouldn't be any limitation on the size of BLOB. Besides, my VpList isn't realy that large (it worked great previously when it was a String working in java client, JDO and MySQL. This was before I move the logic to a session bean). Or is the limitation in Toplink? How can I make it work?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Martin Gainty

from blob routines displayed at
http://lists.mysql.com/commits/11855
the allocation for BLOB column is has an upper limit of max(int) which is 64k
so any column (including BLOB) > 64k in size is truncated

anyone else?
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.

> Date: Wed, 3 Jun 2009 23:42:11 -0700
> From: glassfish@javadesktop.org
> To: users@glassfish.dev.java.net
> Subject: @Lob
>
> I am using gf 2.1, Toplink to MySQL. I have a collection Vplist in my entity bean VpPairList and use @Lob when declaring it. The schema is correctly created with the column as BLOB. My session bean creates the entity correctly and it works. But for some processing, the session bean hits an exception saying that the data is too long:
>
> Internal Exception: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'VPLIST' at row 1
> Error Code: 0
> Call: INSERT INTO VPPAIRLIST (ID, VPLIST) VALUES (?, ?)
> .....
>
> I saw people discussing putting a binary file into a BLOB. So I expect there shouldn't be any limitation on the size of BLOB. Besides, my VpList isn't realy that large (it worked great previously when it was a String working in java client, JDO and MySQL. This was before I move the logic to a session bean). Or is the limitation in Toplink? How can I make it work?
> [Message sent by forum member 'senderj' (senderj)]
>
> http://forums.java.net/jive/thread.jspa?messageID=349063
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

_________________________________________________________________
Lauren found her dream laptop. Find the PC that’s right for you.
http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290
[att1.html]

senderj
Offline
Joined: 2008-09-24

Martin, thanks for the reply.

Whatelse can I do if my object is >64K? Is there a way to detect the size of an object after it is serialized?

Martin Gainty

By @LOB i assume you mean one of the 4 predefined Oracle BLOB entities:
BLOB Binary Large Object
CLOB Character Large Object
BFILE Binary File (RO Binary Datafile stored outside DB)
NCLOB CLOB column that supports Multibyte Character Set

create table LOBTest (
Text CLOB,
Budget BLOB,
Letter BFILE,
tablespace MyTablespace
lob(Text,Budget) store as
(tablespace LOB_Tablespace
storage (initial 100k next 100k pctincrease 0)
chunk 16k pctversion 10 nocache logging);
//initial segment allocation is 100k, consequent segment allocation is 100k
//each lob value is allocated 16k contiguous(default chunk value is 1k)
//pctversion is max percentage of overall LOB storage used for new LOBVersions
//nocache - lob values not stored in memory
//logging - all operations against LOB are recorded in database redo logfiles

//INITIALISATION
BLOB is initialised with EMPTY_BLOB() function e.g.
INSERT INTO TABLE (BLOBColumn) VALUES (EMPTY_BLOB());

CLOB is initialised with EMPTY_CLOB() function
INSERT INTO TABLE (CLOBColumn) VALUES (EMPTY_CLOB());

NCLOB is initialised with EMPTY_CLOB() function
INSERT INTO TABLE (NCLOBColumn) VALUES (EMPTY_NCLOB());

BFILE is initialised with BFILENAME function;
create directory BFILEDIRECTORY as '/u01/bfiledirectory'
INSERT INTO TABLE (BFILENAMEColumn) VALUES (BFILENAME('BFILEDIRECTORY','a.doc'));

ALL Interactions with LOB are thru DBMS_LOB Oracle package you would of course need to source the scriptfile

{ORACLE_HOME}/rdbms/admin/dbmslob.sql
More information for manipulating Oracel LOBs can be seen at
http://www.psoug.org/reference/dbms_lob.html

illustration of BFILENAME column creation available at
http://download-west.oracle.com/docs/cd/B13789_01/server.101/b10759/func...

illustration of BLOB and CLOB column creation available at
http://www.dba-oracle.com/t_table_blob_lob_storage.htm

illustration of NCLOB column available at
http://www.orafaq.com/wiki/NCLOB

HTH
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

> Date: Mon, 8 Jun 2009 21:28:03 -0700
> From: glassfish@javadesktop.org
> To: users@glassfish.dev.java.net
> Subject: Re: RE: @Lob
>
> Martin, thanks for the reply.
>
> Whatelse can I do if my object is >64K? Is there a way to detect the size of an object after it is serialized?
> [Message sent by forum member 'senderj' (senderj)]
>
> http://forums.java.net/jive/thread.jspa?messageID=349891
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

_________________________________________________________________
Windows Liveâ„¢: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
[att1.html]

senderj
Offline
Joined: 2008-09-24

Thanks for the reply. I am using MySQL, so the SQL suggested doesn't apply to me. I finally changed to use string for the column because I found that my program needs a longer time to run when using BLOB (even if I didn't encounter the size problem). Switched to string I can then change the column to MEDIUMTEXT, which is long enough to house the longest VPLIST I've ever had. Thanks for the idea anyway.