0

I am having a java class with one of its attribute:

private byte[] file;

When I upload a image it stores itself in my PostgreSQL database as bytea data (and other attributes stores themselves successfully as well). When I retrieve my entity from DB, everything is retrieved perfectly except the file byte[] is always null (byte data seems not to be retrieved at all).

Any ideas?

Edit: I tried @Lob annotation - did not help.

eXPRESS
  • 425
  • 2
  • 4
  • 19
  • try to use `@Lob` annotation, see https://stackoverflow.com/questions/939673/how-is-a-blob-column-annotated-in-hibernate – Vladimir Vagaytsev Apr 23 '18 at 11:11
  • I did try that even before posting this (I should've mention it) and it did not solve the issue, thanks for suggestion though. – eXPRESS Apr 23 '18 at 11:21
  • 1
    Using LAZY loading? – pirho Nov 27 '18 at 16:31
  • I completely changed the approach in the end and I can't remember how it was, sorry. On one hand it would explain it I guess, on the other hand, it would be very dumb from me. :D – eXPRESS Nov 27 '18 at 18:19
  • 1
    Well not necessarily dumb. I had the same problem so that is why interested. Some pg 9.5 version or so, could not get LAZY work. But now with v11 @Lob defaults nicely to OID tyep column and also LAZY works. – pirho Nov 27 '18 at 20:13
  • Oh, did not know that, thanks for info. And you are right it is not dumb I poorly explained myself, it would be dumb from me not to test EAGER. :) – eXPRESS Nov 29 '18 at 09:07

0 Answers0