2017-03-22 8 views
0

최대 절전 모드 매핑을 사용하고 있기 때문에 데이터베이스에서 BLOB를 읽는 방법. 데이터베이스에 이미지를 저장할 수 있습니다. 그러나 문제를 만드는 데이터베이스에서 BLOB 필드를 읽는 것. Hibernate ANnotations를 사용하지 않고 postgres 데이터베이스에서 BLOB를 읽는 단계별로 안내 할 수 있습니까? 최대 절전 모드 매핑을 사용하고 있습니다.하이버 네이트 주석을 사용하지 않는 최대 절전 모드 매핑을 사용하여 포스트그레스에서 Blob 읽기

답변

0

내가 org.hibernate.type.BlobType을 사용하고이

@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; 
    } 

} 
+0

같은 개체를 만들 수 있습니다. 여기서 Byte [] 배열을 사용하고 있습니다. Blob 형식을 사용하고 있습니다. getBlob 및 setBlob 메서드 –

+0

크기가 blob을 byte []로 바꾼다. –

+0

크기가 큰 데이터를 보유하지 않아야합니다. 즉, 큰 크기를 사용합니다. –