java - Store and retrieve Image by Hibernate -


Can anyone tell me what is the best way to store and how to mimic the image in Hibernate (MySQL)? Is doing

  @Entity @Table (name = "picture") The Public Category Picture Variation Serializable {@Id @Column (name = "id") applies the @ generatedValue private int id; @ Column (name = "format", length = 8) private string format; // @ Basic (fetch = FetchType.LAZY) @ lb@column (name = "context", tapable = true, column definition = "middlebum") personal java.sql.blob myBlobAttribute; // or byte [] Any diff @ManyToOne (fetch = FetchType.EAGER) @JoinColumn (name = "branch_fk", referenced column name = "id", nullable = false) Private branchTT branch;  

And even Piccadio is also I want to know how I implement My PictureDAO to save and retrieve the image.

The version with the byte array is simple.

  Public Category Picture Serial Serializable {Private Byte imageBytes; Public BufferedImage getImage () {InputStream = new byteInInputBrows (imageBytes); Return imageIO.read (in); } Public Zero Setizes (Buffer Image Image) {Buffer Output Stream Out = New ByteOrout OutputStream (); ImageIO.write (image, "PNG" / * for example * /, outside); ImageBytes = out.toByteArray (); }}  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -