?
Solved

spring hibernate update

Posted on 2008-10-23
3
Medium Priority
?
475 Views
Last Modified: 2012-06-27
i got:
Parent and Child

when i save, i use below:
getHibernateTemplate().saveOrUpdate(parent);

so it should will auto save the child by right.

My question is, if my child data is same with database,
so will hibernate update it again?

for example:
child.setName("abc");

but the name "abc which is in db already, will it update again?
0
Comment
Question by:aaaaaa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
jV247 earned 200 total points
ID: 22857027
No, you would need a merged/managed reference to the child for that. See

http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/objectstate.html

Child c = new Child();
...
saveOrUpdate(c);
c.setName("abc"); //won't automatically be saved.

However:

Child nChild = new Child();
Child mChild = merge(nChild);
mChild.setName("abc"); //triggers an update
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question