How does the Java Persistance API handle binary data?
I'm working on a CDN project in Java EE using the Java Per开发者_高级运维sistence API. As such, I'll need to store binary data.
How is that supported? Will I have to store a filename and do read and write operations separately, or can it handle binary data natively?
You can use the @Lob annotation as described here. The example uses a String but if you do like the below example it will store binary data as well.
@Lob
public byte[] getBinaryData() {
return binaryData;
}
精彩评论