| I have debugged the situation and the problem is obvious: From org.hibernate.mapping.Column#getAlias(org.hibernate.dialect.Dialect, org.hibernate.mapping.Table): {{ @Override public String getAlias(Dialect dialect, Table table) { return getAlias( dialect ) + table.getUniqueInteger() + '_'; } }} From org.hibernate.mapping.Column#getAlias(org.hibernate.dialect.Dialect): {{ @Override public String getAlias(Dialect dialect) { final int lastLetter = StringHelper.lastIndexOfLetter( name ); final String suffix = Integer.toString( uniqueInteger ) + '_'; String alias = name; if ( lastLetter == -1 ) { alias = "column"; } else if ( name.length() > lastLetter + 1 ) { alias = name.substring( 0, lastLetter + 1 ); } boolean useRawName = name.length() + suffix.length() <= dialect.getMaxAliasLength() && !quoted && !name.toLowerCase( Locale.ROOT ).equals( "rowid" ); if ( !useRawName ) { if ( suffix.length() >= dialect.getMaxAliasLength() ) { throw new MappingException( String.format( "Unique suffix [%s] length must be less than maximum [%d]", suffix, dialect.getMaxAliasLength() ) ); } if ( alias.length() + suffix.length() > dialect.getMaxAliasLength() ) { alias = alias.substring( 0, dialect.getMaxAliasLength() - suffix.length() ); } } return alias + suffix; } }} the first method calls the second one. The second one returns an alias that is ensured to be no longer than maxAliasLength - it substrings the alias as needed to satisfy that alias + suffix is not longer than maxAliasLength. It returns the resulting alias. The first method then appends table.getUniqueInteger() + '_'; Contract broken. Code from above is from hibernate-core-5.3.7 |