views:

2162

answers:

1

How is a blob column annotated in Hibernate? So far I have a class that has:

@Column( name = "FILEIMAGE" )
private byte[ ] fileimage ;
//
public byte[ ] getFileimage ( ) { return this.fileimage ; }
public void setFilename ( String filename ) { this.filename = filename ; }
+2  A: 

@Lob should do the trick for blob and clob (use String as type)

@Column( name = "FILEIMAGE" )
@Lob(type = LobType.BLOB)
private byte[] fileimage;
HeDinges
dependent on the hibernate version, the Lob annotation could have no type parameter. quote from [here](https://www.hibernate.org/398.html):@Lob no longer has attributes, the lob type (CLOB, BLOB) is guessed. If the underlying type is a String or an array of character then CLOB are used. Othersise BLOB are used.
Fortega
thanks guys for your quick answers. is the sequence important?@Column( name = "FILEIMAGE" , length = 1048576 ) @Lob private byte[ ] fileimage ;