I am writing a Hibernate NamingStrategy for our schema.
Our legacy schema (for some reason!) includes type information in column names. For example:
strproperty
intcustomer
I am implementing the following method from the NamingStrategy interface:
public String propertyToColumnName(String propertyName)
I would like to know the Java type of the property above, so that I could implement our naming strategy such that:
public String getProperty() {
return this.property()
}
would map to strproperty automatically.
For arguments sake say this is the way I would envisage it working (I know this method does not exist):
public String propertyToColumnName(Object propertyName, Class propertyType) {
if (propertyType instanceof String) {
return "str" + propertyName;
} else {
return "int" + propertyName;
}
}
Is there any way to ascertain the type of the Java property from within the naming convention hooks in Hibernate?
Thanks in advance.