Too long column alias - Column.GetAlias() doesn't correctly respect Dialect.MaxAliasLength

Description

Column.GetAlias() currently takes Dialect.MaxAliasLength into account, but not correctly. In some cases it can generate too long aliases.

Problems:
If the column name contains a non-letter, the name will be cut before that character. The code might then NOT fail the test for maximum length, but STILL apply the suffix, which can potentially generate a too long alias.

Secondly, when the GetAlias(dialiect, table) overloaded method is used, the length of the table suffix isn't accounted for.

This problably hasn't been noticed before because the base Dialect sets the MaxAliasLength to just 10 characters, and the only overriding dialects are some of the Sybase dialects. 10 characters is very short and probably the real maximum length is considerably longer in most RDBMS.

Environment

None

Activity

Alex Zaytsev May 2, 2017 at 9:38 PM

Also, this is for Oracle8iDialect.java:

Alex Zaytsev May 2, 2017 at 9:36 PM

I think this fix was "wrong", at least it contradicts the comment on Hibernate's getMaxAliasLength (not sure why the comment itself wasn't ported):

Alex Zaytsev May 1, 2017 at 3:42 AM

Closing issues resolved in 4.1.0

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created August 20, 2016 at 3:14 PM
Updated May 2, 2017 at 9:45 PM
Resolved August 20, 2016 at 11:02 PM
Who's Looking?