0
由於我使用Hibernate映射,如何讀取數據庫中的BLOB。我可以能夠保存圖像數據庫。但是看完數據庫創建問題BLOB字段。你能帶領我一步的閱讀從Postgres數據庫一滴不使用Hibernate註解的一步。我正在使用hibernate映射。閱讀斑點使用Hibernate映射Postgres的不使用Hibernate註解
由於我使用Hibernate映射,如何讀取數據庫中的BLOB。我可以能夠保存圖像數據庫。但是看完數據庫創建問題BLOB字段。你能帶領我一步的閱讀從Postgres數據庫一滴不使用Hibernate註解的一步。我正在使用hibernate映射。閱讀斑點使用Hibernate映射Postgres的不使用Hibernate註解
這樣
@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;
}
}
我使用org.hibernate.type.BlobType創建實體。在這裏,您正在使用byte []數組。我正在使用Blob類型。 getBlob和方法的setBlob變化 –
到BLOB byte []的工作確定 –
我們不應該它不會持有其大小即數據,大尺寸 –