Add code in get/set methods of secondColor to handle this. If the access mode is "property" which is the default, Hibernate will call the get/set methods.
Code:
String secondColor;
public String getSecondColor() {
if (secondColor == null) {
return " ";
}
return secondColor;
}
public void setSecondColor(String secondColor) {
this.secondColor = secondColor;
if (" ".equals(secondColor)) {
this.secondColor = null; // when object is retrieved from database set null back
}
}
public String getSndColor() {
return secondColor;
}
public void setSndColor(String secondColor) {
this.secondColor = secondColor;
}
The other set of get/set methods for SecondColor is for use by the application if you want to use null instead of blank String, otherwise it is not needed.
This is just a sample code to give you an idea.