-->
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: Does EntityManager.merge really merge?
PostPosted: Fri Dec 04, 2009 6:46 pm 
Beginner
Beginner

Joined: Thu Jan 29, 2009 1:24 am
Posts: 20
Hi Everyone,

I've got a JPA+Hibernate app that I'm trying to figure out what exactly the merge function does in EntityManager. In looking closely at our MySQL logs it would appear the merge generates a query which overwrites the state of the entire object to the database. What I would expect to happen though is that the merge compares each field/property of the entity and only overwrites the pieces that have truly changed.

For instance if I have a Dog entity with properties color and species and I change the color property and call merge the resulting query should be
Code:
update Dog set color=?1 where id=?2
instead of the
Code:
update Dog set color=?1, species=?2 where id=?3
as i'm seeing.

Am I misunderstanding what the merge function is doing or its purpose? Is there some setting or setup that I am missing to make sure MySQL is getting more appropriate queries?

Thanks in advance,
Jean-Philippe


Top
 Profile  
 
 Post subject: Re: Does EntityManager.merge really merge?
PostPosted: Mon Dec 07, 2009 3:53 pm 
Beginner
Beginner

Joined: Thu Jan 29, 2009 1:24 am
Posts: 20
Is there really no one who can answer my question? I find this a bit hard to believe. Surely the devs who wrote the implementation would know.

Maybe my question is too confusing. Ok i'll try again. How can I get the EntityManager.merge() function to produce true merge SQL statements where only the field values that have actually been modified are set?


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.