Fixed
Details
Assignee
Steve EbersoleSteve EbersoleReporter
Stephan PalmStephan PalmTime tracking
0.15h loggedComponents
Fix versions
Affects versions
Priority
Major
Details
Details
Assignee
Steve Ebersole
Steve EbersoleReporter
Stephan Palm
Stephan PalmTime tracking
0.15h logged
Components
Fix versions
Affects versions
Priority
Created March 12, 2010 at 3:02 PM
Updated April 22, 2015 at 6:24 PM
Resolved May 10, 2010 at 2:30 PM
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
final String columnName = nameNormalizer.normalizeIdentifierQuoting( col.name() );
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:
if ( identifier.length() == 0) return null;
The function now looks like this:
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; }