Let's assume I have the String property fullName
but I want to represent it as two separate strings as shown in the example below.
Is it possible to set up Hibernate so that it stores the full name in a single column and uses the accessor methods (getFullName
, setFullName
) to do that ?
The problem is that I do not want to declare - just to make Hibernate happy - an unnecessary String field fullName
which will not be used because that would decrease the cleanness of the code.
String lastName;
String firstName;
public String getFullName() {
return firstName+" "+lastName;
}
public void setFullName(String n) {
firstName=extractFirstName(n);
lastName=extractLastName(n);
}