As i am using Hibernate Mapping , how to read the blob from database. I can able to save image in database. But reading the blob field in database creating issues. Can you guide me step by step of reading blob from postgres database without using Hibernate ANnotations. I am using hibernate mapping.
Asked
Active
Viewed 191 times
1 Answers
0
create entity like this
@Entity
@Table(name = "core_file")
@SequenceGenerator(name = "default_gen", sequenceName = "seq_core_file", allocationSize = 1)
public class FileProvider extends BaseEntity<Long> {
@Column(name = "attachment", nullable = false)
private byte[] attachment;
@Column(name = "file_Name")
private String fileName;
@Column(name = "file_Type", nullable = false)
private String mimeType;
@Column(name = "file_Code", nullable = false)
private String fileCode;
@Column(name = "accept_date")
private String acceptDate;
public FileProvider() {
super();
}
public FileProvider(byte[] attachment, String fileName, String mimeType) {
super();
this.attachment = attachment;
this.fileName = fileName;
this.mimeType = mimeType;
}
public byte[] getAttachment() {
return attachment;
}
public void setAttachment(byte[] attachment) {
this.attachment = attachment;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public String getFileCode() {
return fileCode;
}
public void setFileCode(String fileCode) {
this.fileCode = fileCode;
}
public String getAcceptDate() {
return acceptDate;
}
public void setAcceptDate(String acceptDate) {
this.acceptDate = acceptDate;
}
}

ali akbar azizkhani
- 2,213
- 5
- 31
- 48
-
I am using org.hibernate.type.BlobType. Here you are using Byte[] array. I am using type Blob. getBlob and setBlob methods – Sekhar Kumar Mar 23 '17 at 07:16
-
we should not it wont hold data having size i.e., large size – Sekhar Kumar Mar 24 '17 at 15:38
-
I am using this way for larg and small size without problem , what is your problem????!!! – ali akbar azizkhani Mar 25 '17 at 09:44