I have the following problem:
We are writing a web application using Hibernate and Struts. Upon submit, I want to check, if a DB update has be executed or not. So I pull the Object out of the DB and compare it to the data in the form (let's assume, I have a Person object with some attributes like Name, Address, etc.).
Now if the field Address on the web form is empty the form property would give me an "" (Empty String). If I take the Address property which I got from the DB object and compare it to the form property, the comparison would return FALSE because I compare an "" (Empty String) with NULL which obviousley is not the same.
I tried the following methods:
if (StringUtils.equals(formObj.getAddress(), dbObj.getAddress())) {
dbObj.getAddress(formObj.getAddress());
dbObj.update();
}
if (ObjectUtils.equals(formObj.getAddress(), dbObj.getAddress())) {
dbObj.getAddress(formObj.getAddress());
dbObj.update();
}
My question is: Is there a method that could take these to String Values and compares them, whereby "" == NULL would return TRUE?