-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Problem with BLOB update: Hibernate or MySQL?
PostPosted: Wed May 30, 2007 12:25 pm 
Newbie

Joined: Wed May 23, 2007 10:07 am
Posts: 12
Location: Italy
Hi,
I have an entity with a BLOB field. If I update the blob ( by loading a new file) and other entity properties, like filename and content-type, and then i ask the EntityManager to merge the entity, it updates the changed fileds but it never updates the BLOB field.

Is this behaviour depending on Hibernate or MySQL? Or simply I'm doing something wrong??

Thanks for any reply.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 2:27 pm 
Regular
Regular

Joined: Mon May 08, 2006 6:00 am
Posts: 53
Location: India
not sure the exact reason, but work around is, delete and insert :-(


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 3:19 am 
Newbie

Joined: Wed May 23, 2007 10:07 am
Posts: 12
Location: Italy
More than a workaround is an HACK :D


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 6:48 am 
Newbie

Joined: Wed May 23, 2007 10:07 am
Posts: 12
Location: Italy
I went on with my application, but now i really need to solve this problem.

I have searched deeper and what i discovered is that Hibernate doesn't call the getter for my attribute.
Inside my entity Content i have this code.

Code:
   @Column(name = "CONTENT")
   @Basic(fetch=FetchType.LAZY)
   private Blob contentBlob;

   public Blob getContentBlob() {
      return contentBlob;
   }

   public void setContentBlob(Blob contentBlob) {
      this.contentBlob = contentBlob;
   }



When my application call the method
Code:
   public void save(Content content) {
      if (content.getId() == null) {
         entityManager.persist(content);
      } else {
         entityManager.merge(content);
      }
   }


the merge doesn't call the getter...but the funny thing is that the insert work perfectly and even in that case the getter is never called.
So i think i'm missing something, or maybe my debugger does.
How Hibernate access that value??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.