-->
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.  [ 5 posts ] 
Author Message
 Post subject: about dirty checking?(help)
PostPosted: Tue Jun 14, 2005 8:57 pm 
Newbie

Joined: Wed Feb 02, 2005 9:58 pm
Posts: 4
recently i read the book Hibernate in Action.in page 97,when I read another issue to consider is dirty checking,I don't undenstand the below example can avoid the property of a javabean SQL UPDATE:

public String getFirstname() {
return new String(firstname);
}
.

Maybe I don't understand the Hibernate completely,who can say it clearly.
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 9:41 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
What part don't you understand? Have you continued reading?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 9:57 pm 
Newbie

Joined: Wed Feb 02, 2005 9:58 pm
Posts: 4
in page 97 in Hibernate ,the chaper:
3.2.5 Adding logic to accessor methods:

Another issue to consider is dirty checking. Hibernate automatically detects
object state changes in order to synchronize the updated state with the database.
It’s usually completely safe to return a different object from the getter method to
the object passed by Hibernate to the setter. Hibernate will compare the objects
by value—not by object identity—to determine if the property’s persistent state
needs to be updated. For example, the following getter method won’t result in
unnecessary SQL UPDATEs:
public String getFirstname() {
return new String(firstname);
}

I don't understand why the accessor method can avoid the SQL UPDATES.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 10:03 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Do you understand the difference between "pass by value" and "pass by reference" in Java?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 10:11 pm 
Newbie

Joined: Wed Feb 02, 2005 9:58 pm
Posts: 4
thank u alert me .I understand it.thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.