[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5006) hibernate.globally_quoted_identifiers=true and Annotations tests

Stephan Palm (JIRA) noreply at atlassian.com
Fri Mar 12 08:03:47 EST 2010


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


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: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list