java - Using Property Type Info Hibernate NamingStrategy -
I am writing the hibernate naming strategy for our schema.
Our legacy schema (for some reason!) Column names include information types, for example:
strproperty intcustomer I am implementing the following method from the NamingStrategy interface:
public string propertyToColumnName (string property nanam) To know, so that I can implement our naming strategy which:
public string getProperty ( } {This return.property ()} will automatically map strproperty
For the argument it is to say that it's the way I used to do it (I know that this method does not exist):
public string multiplication columnname (object property name, class property type) {If (propertyType example of string) {return "str" + PropertyName; } Else {return "int" + propertyName; }} Is there any way to detect the type of Java property from within the naming convention hook in Hibernate?
Thanks in advance.
/ div>
I do not think the interface is designed with that thing - at first glance It seems that there is no way caller about propertyToColumnName ()
However, I think that for javadocs for propertyToColumnName () It says that "a column name for an property path expression " can be passed in this method by the hibernate in this method, It would be good to check: If it is actually completely qualified with the name of the class, you can parse the name of the class and use the reflection on that square to determine the property type.
Alternatively, do not forget that you can always specify column names in your mapping files (or I think if you use them):
< Strong> & lt; Property name = "blah" column = "intblah" />
That can be a simple approach.
Comments
Post a Comment