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

Table in sqlserver:

create table Imagetable(
Image_Name varchar(20) not null primary key,
Image_Data varbinary(max) not null
);

I have tried to do it like this:
EntityClass:

public class ImageImport {
	private String name;
	private FileInputStream ins;	
	//getter,setter
}

Mapping file:

<hibernate-mapping package="com.yp.entity">
	<class name="ImageImport" table="Imagetable">
		<id name="name" column="Image_Name" length="20">
			<generator class="native"/>
		</id>
		<property name="ins" column="Image_Data"/>
	</class>
</hibernate-mapping>

When app start, the error message:
org.hibernate.MappingException: Could not determine type for: java.io.FileInputStream, at table: Imagetable, for columns: [org.hibernate.mapping.Column(Image_Data)]

And I also tried to retrieve data from sql server.

Entity class:

public class ImageExport {
	private String name;
	private Blob image;
	//getter,setter
}

Mapping file:

<hibernate-mapping package="com.yp.entity">
	<class name="ImageExport" table="Imagetable">
		<id name="name" column="Image_Name" length="20">
			<generator class="native"/>
		</id>
		<property name="image" column="Image_Data"/>
	</class>

The code of retrieving image:

1. ImageExport image= session.get(ImageExport.class, "first");
2. FileOutputStream outs = new FileOutputStream(new File(path));
3. outs.write(blob.getBytes(1, (int) blob.length()));
4. outs.close();

when execute to the third line, error message:
com.microsoft.sqlserver.jdbc.SQLServerException: The TDS protocol stream is not valid

I have successfully done it by using pure jdbc methods with this tutorial

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"/>

My problem solved, thanks a lot.