Using EclipseLink JPA to Bind Strings Over 255 Characters

I inherited a project that uses EclipseLink JPA to store objects in any SQL database. It currently ships with a local Derby DB distribution. During some tests, I found that the program throws the following exception:

012-08-03 10: 21: 11.357 - UnitOfWork (32349505) - Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java. sql.SQLDataException: truncation error was encountered while trying to compress VARCHAR 'some really really long text' to length 255. Error code: 20000

Obviously, VARCHAR is not (usually) suitable for storing strings longer than 255 characters, but I did not find a piece of code where the object variable is explicitly assigned to the VARCHAR field. I understand that JPA or EclipseLink will automatically assign this to you, so my question, where I haven't found a simple answer yet, is this:

How can I make sure that EclipseLink / JPA stores strings longer than 255 characters?

Greetings

+5
source share
3 answers

, Clob. @Lob; String Clob. . . , , (.. VARCHAR), .

+10

, 255 . . :

Java Type - byte [], java.lang.Byte [], java.sql.Clob

Java DB, Derby, CloudScape - CLOB (64000)

Oracle - LONG

DB2 - CLOB (64000)

Sybase - TEXT

MSSQL - TEXT

MySQL - (64000)

+1

@Column String 255, 4kB. 'length' 255

@Column ( = 1024)

,

+1

All Articles