Using ImprovedNamingStrategy but getting odd output. I am not sure if it is a bug or if it is by-design. When placing an explicit column name and using ImprovedNamingStrategy. I am inclined to think it is a bug but I see that it is released in Hibernate 3.
Q: Is this a bug or am I doing something wrong?
Code:
input output expected-output
TEAM_ID tea_m_id team_id
GS_USER g_s_user gs_user
// from ImprovedNamingStrategy
Code:
private static String hibV21addUnderscores(String name) {
StringBuffer buf = new StringBuffer(name.replace('.', '_'));
for (int i = 1; i < buf.length() - 1; i++) {
if ('_' != buf.charAt(i - 1)
&& Character.isUpperCase(buf.charAt(i))
&& !Character.isUpperCase(buf.charAt(i + 1))) {
buf.insert(i++, '_');
}
}
return buf.toString().toLowerCase();
}
// However, if a line is added the intended result (team_id, gs_user) is realized.
Code:
private static String modifiedAddUnderscores(String name) {
StringBuffer buf = new StringBuffer(name.replace('.', '_'));
for (int i = 1; i < buf.length() - 1; i++) {
if (
'_' != buf.charAt(i - 1) &&
'_' != buf.charAt(i + 1) &&Code:
// this condition was added
Character.isUpperCase(buf.charAt(i)) &&
!Character.isUpperCase(buf.charAt(i + 1))
) {
buf.insert(i++, '_');
}
}
return buf.toString().toLowerCase();
}
Thanks in advance,
John