Maven dependencies used all over JPA tutorials same. Please follow "Setting up Project" section to understand about project configuration.
persistence.xml and other code files reused from How to Persist an Entity in data base using JPA?
Each Sample application from download includes SQL file also.

LOB – large objects in database :

  • Databases will provide data types to store large objects (LOBs) in columns, this types will allow gigabyte ranges.
  • LOBs come in two flavors in the database: character large objects, called CLOBs, and binary large objects, or BLOBs.
  • As their names imply, a CLOB column holds a large character sequence, and a BLOB column can store a large byte sequence.
  • Mostly CLOB is to store text based files and BLOB is to store media files like images, videos,mp3 etc..
  • Data type names may vary in different databases(Oracle, MySql etc..).
  • JPA provides @Lob annotation to work with Large objects.

Example Application :

Database table Structure :

User Entity :

Test Code :

Verify in database :

  • Open table data in mysql workbench –> Right click on PROFILE_PIC column –> Select “Open Value In Editor” –> Select “Image” from opened window. you can see saved image in PROFILE_PIC column. See below screen.
Download Application – (25 KB)