Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @Lob @Column (length=16777215) doesn't work with MySql to get a MEDIUMBLOB
@Lob @Column (length=16777215) doesn't work with MySql to get a MEDIUMBLOB [message #388441] Fri, 29 May 2009 05:46 Go to next message
Martin Dames is currently offline Martin Dames
Messages: 28
Registered: July 2009
Junior Member
Hi guys,

I have a simple Table where one column should be from type LOB. I want to
store some picture data.
When Im connecting to MySQL with EclipseLink (JPA), it creates the tables
automatically and set the right column type for MySQL. But it just creates
columns from type BLOB (which is limited to 64kb in MySQL) and not
MEDIUMBLOB (which would be sufficient for my images).

One solution I found is to set the column length to a size greater than
64kb (see example below) so that EclipseLink (JPA) would create a column
from type MEDIUMBLOB if it is connected to MySQL automatically. This
doesn't work... it just creates columns from type BLOB, doesn't matter
which length im defining for the column.

I triple checked if the tables are being created by JPA, old and not
dropped tables are not the error.

Is this a bug? Thank you.


My annotated entity attribute:
@Lob
@Basic(fetch=FetchType.LAZY)
@Column (length=16777215, name="IMAGE") // length for mysql mediumblob
private byte[] mymage;
Re: @Lob @Column (length=16777215) doesn't work with MySql to get a MEDIUMBLOB [message #388478 is a reply to message #388441] Sun, 31 May 2009 23:26 Go to previous message
Doug Clarke is currently offline Doug Clarke
Messages: 155
Registered: July 2009
Senior Member
If you ever need to customize the types used in the schema generation you
can use the columnDefinition attribute of the @Column annotation. This
allows you to specify the exact string that will be used.

@Lob
@Basic(fetch=FetchType.LAZY)
@Column(columnDefinition="MEDIUMBLOB(?)")
private byte[] image;

Doug
Previous Topic:List of Supertype and @OrderBy
Next Topic:EclipseLink does not store in database
Goto Forum:
  


Current Time: Thu Aug 21 04:19:11 EDT 2014

Powered by FUDForum. Page generated in 0.02011 seconds