HHH-4911 render referencedColumnName case insensitive

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18794 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Emmanuel Bernard 2010-02-12 17:22:48 +00:00
parent 8514f5a15e
commit b3dca5d4d6
5 changed files with 10 additions and 7 deletions

View File

@ -439,7 +439,7 @@ public class BinderHelper {
return persistentClass; //shortcut for implicit referenced column names return persistentClass; //shortcut for implicit referenced column names
} }
PersistentClass current = persistentClass; PersistentClass current = persistentClass;
Object result = null; Object result;
boolean found = false; boolean found = false;
do { do {
result = current; result = current;

View File

@ -54,7 +54,8 @@ public class CopyIdentifierComponentSecondPass implements SecondPass {
if ( referencedColumnName == null || BinderHelper.isDefault( referencedColumnName ) ) { if ( referencedColumnName == null || BinderHelper.isDefault( referencedColumnName ) ) {
break; break;
} }
columnByReferencedName.put( referencedColumnName, joinColumn ); //JPA 2 requires referencedColumnNames to be case insensitive
columnByReferencedName.put( referencedColumnName.toLowerCase(), joinColumn );
} }
//try default column orientation //try default column orientation
int index = 0; int index = 0;
@ -103,7 +104,8 @@ public class CopyIdentifierComponentSecondPass implements SecondPass {
if ( isExplicitReference ) { if ( isExplicitReference ) {
final String columnName = column.getName(); final String columnName = column.getName();
logicalColumnName = mappings.getLogicalColumnName( columnName, referencedPersistentClass.getTable() ); logicalColumnName = mappings.getLogicalColumnName( columnName, referencedPersistentClass.getTable() );
joinColumn = columnByReferencedName.get( logicalColumnName ); //JPA 2 requires referencedColumnNames to be case insensitive
joinColumn = columnByReferencedName.get( logicalColumnName.toLowerCase() );
} }
else { else {
joinColumn = columnByReferencedName.get( "" + index ); joinColumn = columnByReferencedName.get( "" + index );

View File

@ -564,7 +564,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
for (Ejb3JoinColumn ejb3Column : columns) { for (Ejb3JoinColumn ejb3Column : columns) {
String logicalReferencedColumnName = ejb3Column.getReferencedColumn(); String logicalReferencedColumnName = ejb3Column.getReferencedColumn();
if ( StringHelper.isNotEmpty( logicalReferencedColumnName ) ) { if ( StringHelper.isNotEmpty( logicalReferencedColumnName ) ) {
String referencedColumnName = null; String referencedColumnName;
try { try {
referencedColumnName = mappings.getPhysicalColumnName( logicalReferencedColumnName, matchingTable ); referencedColumnName = mappings.getPhysicalColumnName( logicalReferencedColumnName, matchingTable );
} }

View File

@ -443,7 +443,8 @@ public class TableBinder {
for (Ejb3JoinColumn joinCol : columns) { for (Ejb3JoinColumn joinCol : columns) {
String referencedColumn = joinCol.getReferencedColumn(); String referencedColumn = joinCol.getReferencedColumn();
referencedColumn = mappings.getPhysicalColumnName( referencedColumn, table ); referencedColumn = mappings.getPhysicalColumnName( referencedColumn, table );
if ( referencedColumn.equals( col.getName() ) ) { //In JPA 2 referencedColumnName is case insensitive
if ( referencedColumn.equalsIgnoreCase( col.getName() ) ) {
//proper join column //proper join column
if ( joinCol.isNameDeferred() ) { if ( joinCol.isNameDeferred() ) {
joinCol.linkValueUsingDefaultColumnNaming( joinCol.linkValueUsingDefaultColumnNaming(

View File

@ -22,7 +22,7 @@ public class Dependent {
@MapsId("empPK") @MapsId("empPK")
@JoinColumns({ @JoinColumns({
@JoinColumn(name = "FK1", referencedColumnName = "firstName"), @JoinColumn(name = "FK1", referencedColumnName = "FIRSTNAME"),
@JoinColumn(name = "FK2", referencedColumnName = "lastName") @JoinColumn(name = "FK2", referencedColumnName = "lastName")
}) })
@ManyToOne @ManyToOne