After some investigation I found bug HHH-2680 http://opensource.atlassian.com/projects/hibernate/browse/HHH-2680
Here is patch from 2008 for this issue and also technique how to avoid it. Instead of: session.merge(domain); // changes blob value to 44 Changing it to this avoids the problem: Domain merged = (Domain) session.merge(domain); merged.setBlob(Hibernate.createBlob(domain.getBlob().getBinaryStream())); But maybe your idea is better. When you do real merge can you do getBlob().getOutputStream().write...? Pavel On Wed, May 5, 2010 at 9:16 PM, Patrik Nordwall <patrik.nordw...@gmail.com> wrote: > > Intersting, any idea of how we should solve it? > Do you know if it is the same when using @javax.persistence.Lob ? > > Feels like a stupid limitation in Hibernate. Is it the same in EclipseLink? > > Maybe we could check if the id is not assigned and then use persist instead > of merge. > You can of course do that in your own AccessObject right away. > > /Patrik > > > > Sascha Broich wrote: >> >> Hi, >> >> as I discovered, the Blob will not be saved for new entities in Hibernate >> because the save operation uses merge, which leaves the Blob behind, as >> org.hibernate.type.BlobType says: "//Blobs are ignored by merge()". >> >> It seems to be in the EJB3 spec, as a forum entry hints: >>>>As per the EJB3 spec "Fields or properties of type java.sql.Blob and > java.sql.Clob are ignored by the merge operation."<< >> <https://forum.hibernate.org/viewtopic.php?f=1&t=942365> >> >> This is unfortunate because Sculptor uses merge for saving entites. >> >> >> Regards, >> Sascha Broich >> >> -- >> Sascha Broich >> Development >> >> TSA - Teleport Sachsen-Anhalt Service GmbH >> Herrenstraße 20 - D-06108 Halle >> >> Tel: +49 39203 8 2524 - Fax: +49 39203 8 2511 >> E-Mail: sascha.bro...@tsa.de >> >> Firmensitz: Steinfeldstraße 5, D-39179 Barleben >> Niederlassung: Herrenstraße 20, D-06108 Halle >> Geschäftsführer: Marco Langhof, Thomas Patzelt >> Prokurist: Heiko Bosse >> Amtsgericht: Stendal HRB 6388 >> http://www.tsa.de >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Fornax-developer mailing list >> Fornax-developer@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/fornax-developer >> >> > > -- > View this message in context: > http://old.nabble.com/Saving-Blobs-tp28445492s17564p28465944.html > Sent from the Fornax-Platform mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > _______________________________________________ > Fornax-developer mailing list > Fornax-developer@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/fornax-developer > ------------------------------------------------------------------------------ _______________________________________________ Fornax-developer mailing list Fornax-developer@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fornax-developer