-->
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.  [ 2 posts ] 
Author Message
 Post subject: Persisting new object with merge doesn't save binary data
PostPosted: Mon May 22, 2006 3:07 pm 
Newbie

Joined: Fri Mar 17, 2006 4:48 pm
Posts: 3
I have simple Image object which has a binary attribute. I read a file and set the binary attribute of the Image object. When I try to call

Code:
Image imageObject = EntityManager.merge( imageObject );


The image gets stored in the database table but its binary data is nulled. I want to call merge because it returns the new merged object. Now if I run the following code the binary data gets stored and I obtain the new instance of the persist object.

Code:
EntityManager.persist( imageObject );
EntityManager.refresh( imageObject);


Why would this work with persist but not with merge?

Here is my Image class:

Code:
import java.sql.Blob;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;

@Entity
public class Image {

   private Integer width;
   private Integer height;
   private Blob bin;
   private Integer fileSize;
   
   public Image() {}

   public void setWidth(Integer width) {
      this.width = width;
   }

   public Integer getWidth() {
      return width;
   }

   public void setHeight(Integer height) {
      this.height = height;
   }

   public Integer getHeight() {
      return height;
   }

   public void setBin(Blob binary) {
      this.bin = binary;
   }

   @Basic(fetch=FetchType.LAZY)
   @Column(columnDefinition="MEDIUMBLOB")
   public Blob getBin() {
      return bin;
   }

   public void setFileSize(Integer fileSize) {
      this.fileSize = fileSize;
   }

   public Integer getFileSize() {
      return fileSize;
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 18, 2006 2:20 pm 
Newbie

Joined: Sun Jun 18, 2006 1:56 pm
Posts: 2
Check the EJB-Persistence specification. As far as I understand your problem, this is the supposed behaviour for merge.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.