Column.getAlias(Dialect dialect) generates aliases longer than
Dialect.getMaxAliasLenght()
------------------------------------------------------------------------------------------
Key: HHH-2324
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2324
Project: Hibernate3
Type: Bug
Versions: 3.0.5, 3.2.0.ga
Reporter: Matthias Koenig
org.hibernate.mapping.Column.getAlias(Dialect dialect) doesn't honor
Dialect.getMaxAliasLenght() all the time.
Given:
- a column named "ABCDEFGHIK_X"
- Dialect.getMaxAliasLenght() = 10
- uniqueInteger = 12
getAlias generates the alias "ABCDEFGHIK12_" which is over 10 characters (13
actually).
The problem happens, whenever an alias gets shortened due to an non-letter character and
the shortened alias is less than or equal to Dialect.getMaxAliasLenght().
One possible fix could be another length check befor appending unique:
public String getAlias(Dialect dialect) {
String alias = name;
String unique = Integer.toString(uniqueInteger) + '_';
int lastLetter = StringHelper.lastIndexOfLetter(name);
if ( lastLetter == -1 ) {
alias = "column";
}
else if ( lastLetter < name.length()-1 ) {
alias = name.substring(0, lastLetter+1);
}
if ( alias.length() > dialect.getMaxAliasLength() ) {
alias = alias.substring( 0, dialect.getMaxAliasLength() - unique.length() );
}
boolean useRawName = name.equals(alias) &&
!quoted &&
!name.toLowerCase().equals("rowid");
if ( useRawName ) {
return alias;
}
else {
if ( alias.length() + unique.length() > dialect.getMaxAliasLength() ) {
alias = alias.substring( 0, dialect.getMaxAliasLength() - unique.length() );
}
return alias + unique;
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira