[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5006?page=c...
]
Jaka Jaksic commented on HHH-5006:
----------------------------------
The issue is still present in 3.5.1.
The problem stems from the fact that a @Column annotation without a name attribute returns
an empty string as the name value, which somewhere down the road gets treated as if the
value was set. If there are at least two such columns, it ultimately causes this
exception:
org.hibernate.MappingException: Repeated column in mapping for entity: test.QuotingBug
column: (should be mapped with insert="false" update="false")
at
org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:676)
(This is because all such columns get assigned an empty name.)
Stephan's proposed fix seems to fix the issue.
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
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:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira