How to write mapping file and java entity class to store and retrieve images, binary files in SQL Server

Mapping the Blob property as FileInputStream is not a good idea since that field would only be consumed once and requires to be closed after opening it.

Therefore, as we explained in the User Guide, you need to use either Blob or byte[].

@Lob
private byte[] image;

or with XML mappings:

<property name="image" column="Image_Data" type="blob"/>

or

<property name="image" column="Image_Data" type="binary"/>