0 Replies Latest reply on Aug 28, 2008 6:14 PM by grundor

    How to force reload of EntityHome object?

      I have an issue related to a Blob field I am persisting to my database using Hibernate JPA implementation.


      Basically from what I can tell after persisting or updating my entity to the database I am not able to call Blob.getBytes()  - it gives me the following exception:


      Caused by: java.lang.UnsupportedOperationException: Blob may not be manipulated from creating session
           at org.hibernate.lob.BlobImpl.excep(BlobImpl.java:104)
           at org.hibernate.lob.BlobImpl.getBytes(BlobImpl.java:50)
           at com.leagueunited.entity.util.Image.getImage(Image.java:69)
      



      From what I have read, I need to reload the entity from the database after persisting, prior to calling my getImage() routine.


      My problem (probably a simple solution) is that I can't seem to force a reload on the entity.


      Here is what I have tried:


          public void updatePhoto() {
               Photo photo = photoHome.getDefinedInstance();
               if (photo == null)
                    return;
               
               if (photoHome.update() == "updated") {
                   // Force reload from db to correctly load image blob
                   photoHome.clearInstance();
                   photoHome.setId(photo.getPhotoId());
               }
          }
      



      How can I force photoHome (EntityHome) to reload the entity from the database?  Is there some kind of dirty flag I need to set?


      -Mark