Richard, Thanks for your reply. I would like to clarify my understanding about what you have mentioned.
Here is one of my VO generated thru JDeveloper IDE, it has both equals() and hashCode() methods overriden. So now to you point, I can use equals() method too? right? But I still have to store the original VO and new VO and compare it. If I were to use hashCode(), does it return different int value for CustomerEmpVO oldVO = new CustomerEmpVO(); ........old.set all the properties......... CustomerEmpVO newVO = new CustomerEmpVO(); ......new.set all the properties .......... int oldValue = old.hashCode(); int newValue = new.hashCode(); if (oldValue == newValue) then VOs are same else different? OR oldVO.equals(newVO) is better ? Here is VO public class CustomerEmpVO implements Serializable { private String natCode; private String natDesc; private String cmdCode; private String cmdName; ... all the accessor methods ........ @Override public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof CustomerEmpVO)) { return false; } final CustomerEmpVO other = (CustomerEmpVO) object; if (!(natCode == null ? other.natCode == null : natCode.equals(other.natCode))) { return false; } if (!(natDesc == null ? other.natDesc == null : natDesc.equals(other.natDesc))) { return false; } if (!(cmdCode == null ? other.cmdCode == null : cmdCode.equals(other.cmdCode))) { return false; } if (!(cmdName == null ? other.cmdName == null : cmdName.equals(other.cmdName))) { return false; } return true; } @Override public int hashCode() { final int PRIME = 37; int result = 1; result = PRIME * result + ((natCode == null) ? 0 : natCode.hashCode()); result = PRIME * result + ((natDesc == null) ? 0 : natDesc.hashCode()); result = PRIME * result + ((cmdCode == null) ? 0 : cmdCode.hashCode()); result = PRIME * result + ((cmdName == null) ? 0 : cmdName.hashCode()); return result; } From: Richard Yee <r...@cruzio.com> To: "user-java@ibatis.apache.org" <user-java@ibatis.apache.org> Date: 03/31/2009 09:21 AM Subject: Re: How to Compare database record before UPDATE using iBatis? Why don't you override the Object.hashcode() method on your VO and call it and save the value when you retrieve the record. Call it again when the user submits their changes. If the values are different, the a change was made. -Richard Sent from my iPhone On Mar 31, 2009, at 4:54 AM, Jasmin Mehta <jasmin_me...@nexweb.org wrote: I thought the Subject line of my question earlier was kind of misleading. Here is the same question with suitable subject line. From: Jasmin Mehta <jasmin_me...@nexweb.org To: user-java@ibatis.apache.org Date: 03/31/2009 07:50 AM Subject: Check database before INSERT in iBatis Hi, I have customer registration web application. Where it takes 3 pages to complete the process before submit. Once customer is registered, i.e. the records are inserted into 3 different tables then user can edit the registration. Right now, I have a code that retrieves the record from each table and store it into Value Object class (model) and keep that into session until I update the records at the end of 3 pages. I update the record only if any value is different from VO to new ActionForm being edited else not updating. Is there any shorter way of doing this task in iBatis? Thanks Jasmin ****************************************************************************** This email and any files transmitted with it are intended solely for the use of the individual or agency to whom they are addressed. If you have received this email in error please notify the Navy Exchange Service Command e-mail administrator. This footnote also confirms that this email message has been scanned for the presence of computer viruses. Thank You! ******************************************************************************