0

I want to clear a @Lob field from a Model.

In the model I have something like this for the image field:

@Lob
public byte[] image;

If I do something like this:

theModel.image = null;
theModel.update();

It doesn't remove the data from the field. I find this useful because not every time the model is updated (from a form) an image will be submited to modify the existing one.

But, what can I do to remove the image when needed? Is there an in-framework way to do this? WIll I have to update it "manually" (i.e.: sql...)?

Daniel López Lacalle
  • 6,715
  • 3
  • 25
  • 23
  • 1
    TIP: don't keep files in DB, it's _expensive_, imho it's better to keep them in file system and in DB store only paths (preferably relative, as they're shorter) – biesior Apr 29 '14 at 10:40
  • 1
    see i.e. this answer: http://stackoverflow.com/a/3751/1066240 – biesior Apr 29 '14 at 10:42

0 Answers0