]
Steve Ebersole updated HHH-5006:
--------------------------------
Fix Version/s: 3.6
3.5.2
hibernate.globally_quoted_identifiers=true and Annotations tests
----------------------------------------------------------------
Key: HHH-5006
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5006
Project: Hibernate Core
Issue Type: Bug
Components: annotations, core
Affects Versions: 3.5.0-CR-2
Environment: eclipse galileo
jdk 1.6
Server library JBoss 6.0 M2
(actually I don`t think you need any of this information)
Reporter: Stephan Palm
Assignee: Steve Ebersole
Fix For: 3.5.2, 3.6
Attachments: QuotingBug.java
If I use hibernate.globally_quoted_identifiers=true in order to quote all identifiers,
then the mapping for column names breakes if I have a column with a @Column annotation but
without a @Column(name=<COLUMN_NAME>). The mapping for the column name then turns
out to be ``. Which leads to problems when creating new tables.
I was able to track the error back to
{code}
final String columnName = nameNormalizer.normalizeIdentifierQuoting( col.name() );
{code}
from Ejb3Column.java.
col.name() returns an empty string because the name was not explicitly set.
nameNormalizer.normalizeIdentifierQuoting( col.name() ) then makes `` from the empty
string.
I was able to fix this problem by adding a guard to the
nameNormalizer.normalizeIdentifierQuoting function:
{code}
if ( identifier.length() == 0)
return null;
{code}
The function now looks like this:
{code}
public String normalizeIdentifierQuoting(String identifier) {
if ( identifier == null ) {
return null;
}
if ( identifier.length() == 0)
return null;
// Convert the JPA2 specific quoting character (double quote) to Hibernate's (back
tick)
if ( identifier.startsWith( "\"" ) && identifier.endsWith(
"\"" ) ) {
return '`' + identifier.substring( 1, identifier.length() - 1 ) +
'`';
}
// If the user has requested "global" use of quoted identifiers, quote this
identifier (using back ticks)
// if not already
if ( isUseQuotedIdentifiersGlobally() && ! ( identifier.startsWith(
"`" ) && identifier.endsWith( "`" ) ) ) {
return '`' + identifier + '`';
}
return identifier;
}
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: