Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [TENEO] Unable to save a clob type attribute during merge
[TENEO] Unable to save a clob type attribute during merge [message #1249524] Tue, 18 February 2014 10:34 Go to next message
Minu martin is currently offline Minu martinFriend
Messages: 7
Registered: May 2013
Junior Member
I have a generic application and the entities are generated dynamically run time.
I have an ecore model with an attribute which is annotated as a clob data type with this annotation:
@Lob
@Column(length=52428800)
@Type(type="clob")


I am using dynamic hibernate map for entities and not java classes.
I am trying to create an object with a file attribute.
Before performing create I need to do a hibernate merge operation.
This is to avoid exception in case any instance of the request(associated instances) already exists in session .
But in this case while merging the object with file attribute, the file attribute value becomes null after merge and hence file attribute does not get inserted. But if I try to save the object with session.save, it inserts the file attribute value succesfully.

Is there any reason merge cannot handle this attribute of clob data type?Or am I missing something?
Re: [TENEO] Unable to save a clob type attribute during merge [message #1250426 is a reply to message #1249524] Wed, 19 February 2014 08:29 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Minu,
I did a quick google search and it seems that clob/blob's are ignored in merge operations (by hibernate). But I am not
sure if that has been solved in later hibernate versions. The links I found are not that clear on it.

Can you ask your question on the hibernate forum?

Btw, instead of merge, in my experience with json (de-)serialization. When doing the de-serialization I resolve the
references also against data in the database, so then the de-serialized objects are automatically part of the session.
I don't know your environment, but maybe you can already do resolving against the session objects in your code, so
instead of creating new copies of objects, check if they exist in the database, use hibernate to read it, then the
object graph becomes a mix of new and existing objects which can be persisted using saveOrUpdate. My experience is that
this is a bit 'safer' than doing merge.

Or alternatively, do a manual merge yourselve, using the eclass/efeatures it is quite doable to write your own merge
code (not completely trivial either..). But maybe you can customize/do your own merge specifically for the clob field.

gr. Martin

https://hibernate.atlassian.net/browse/HHH-2680
http://stackoverflow.com/questions/21230480/java-sql-clob-error-in-hibernate-merging
https://forum.hibernate.org/viewtopic.php?f=1&t=1000531&sid=fa88d89e806f559064e42057062fb4bb

On 02/18/2014 11:34 AM, Minu martin wrote:
> I have a generic application and the entities are generated dynamically run time.
> I have an ecore model with an attribute which is annotated as a clob data type with this annotation:
>
> @Lob
> @Column(length=52428800)
> @Type(type="clob")
>
>
> I am using dynamic hibernate map for entities and not java classes.
> I am trying to create an object with a file attribute.
> Before performing create I need to do a hibernate merge operation.
> This is to avoid exception in case any instance of the request(associated instances) already exists in session .
> But in this case while merging the object with file attribute, the file attribute value becomes null after merge and
> hence file attribute does not get inserted. But if I try to save the object with session.save, it inserts the file
> attribute value succesfully.
>
> Is there any reason merge cannot handle this attribute of clob data type?Or am I missing something?


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [TENEO] Unable to save a clob type attribute during merge [message #1251274 is a reply to message #1250426] Thu, 20 February 2014 03:49 Go to previous message
Minu martin is currently offline Minu martinFriend
Messages: 7
Registered: May 2013
Junior Member
Thanks for the suggestions Martin. Will try save-update instead of merge.
Previous Topic:[CDO] Could not activate TCPClientConnector on CDO Hibernate Client/server example
Next Topic:EOperation model parameters
Goto Forum:
  


Current Time: Wed Apr 24 23:39:03 GMT 2024

Powered by FUDForum. Page generated in 0.02876 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top