Solved

spring hibernate update

Posted on 2008-10-23
3
461 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 50 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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordlen challenge 3 86
micro services spring boot application error 3 330
print map entry 34 79
Java array sort 10 59
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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.

738 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