HHH-12119 - Fix NameQueryTupleTransformer discarding alias name case.
This commit is contained in:
parent
db2e3906ab
commit
e3cc2d78e9
|
@ -55,6 +55,7 @@ public class NativeQueryTupleTransformer extends BasicTransformerAdapter {
|
|||
private Object[] tuple;
|
||||
|
||||
private Map<String, Object> aliasToValue = new LinkedHashMap<>();
|
||||
private Map<String, String> aliasReferences = new LinkedHashMap<>();
|
||||
|
||||
public NativeTupleImpl(Object[] tuple, String[] aliases) {
|
||||
if ( tuple == null ) {
|
||||
|
@ -68,7 +69,8 @@ public class NativeQueryTupleTransformer extends BasicTransformerAdapter {
|
|||
}
|
||||
this.tuple = tuple;
|
||||
for ( int i = 0; i < tuple.length; i++ ) {
|
||||
aliasToValue.put( aliases[i].toLowerCase(), tuple[i] );
|
||||
aliasToValue.put( aliases[i], tuple[i] );
|
||||
aliasReferences.put( aliases[i].toLowerCase(), aliases[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,11 +83,11 @@ public class NativeQueryTupleTransformer extends BasicTransformerAdapter {
|
|||
|
||||
@Override
|
||||
public Object get(String alias) {
|
||||
final String lowerCasedAlias = alias.toLowerCase();
|
||||
if (!aliasToValue.containsKey(lowerCasedAlias)) {
|
||||
throw new IllegalArgumentException( "Unknown alias [" + alias + "]" );
|
||||
final String aliasReference = aliasReferences.get( alias.toLowerCase() );
|
||||
if ( aliasReference != null && aliasToValue.containsKey( aliasReference ) ) {
|
||||
return aliasToValue.get( aliasReference );
|
||||
}
|
||||
return aliasToValue.get(lowerCasedAlias);
|
||||
throw new IllegalArgumentException( "Unknown alias [" + alias + "]" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -200,9 +200,9 @@ public class TupleNativeQueryTest extends BaseEntityManagerFunctionalTestCase {
|
|||
List<TupleElement<?>> result = tuples.get(0).getElements();
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(BigInteger.class, result.get(0).getJavaType());
|
||||
assertEquals("id", result.get(0).getAlias());
|
||||
assertEquals("ID", result.get(0).getAlias());
|
||||
assertEquals(String.class, result.get(1).getJavaType());
|
||||
assertEquals("firstname", result.get(1).getAlias());
|
||||
assertEquals("FIRSTNAME", result.get(1).getAlias());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -362,9 +362,9 @@ public class TupleNativeQueryTest extends BaseEntityManagerFunctionalTestCase {
|
|||
List<TupleElement<?>> result = tuples.get(0).getElements();
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(BigInteger.class, result.get(0).getJavaType());
|
||||
assertEquals("id", result.get(0).getAlias());
|
||||
assertEquals("ID", result.get(0).getAlias());
|
||||
assertEquals(String.class, result.get(1).getJavaType());
|
||||
assertEquals("firstname", result.get(1).getAlias());
|
||||
assertEquals("FIRSTNAME", result.get(1).getAlias());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -524,9 +524,9 @@ public class TupleNativeQueryTest extends BaseEntityManagerFunctionalTestCase {
|
|||
List<TupleElement<?>> result = tuples.get(0).getElements();
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(BigInteger.class, result.get(0).getJavaType());
|
||||
assertEquals("id", result.get(0).getAlias());
|
||||
assertEquals("ID", result.get(0).getAlias());
|
||||
assertEquals(String.class, result.get(1).getJavaType());
|
||||
assertEquals("firstname", result.get(1).getAlias());
|
||||
assertEquals("FIRSTNAME", result.get(1).getAlias());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -686,9 +686,9 @@ public class TupleNativeQueryTest extends BaseEntityManagerFunctionalTestCase {
|
|||
List<TupleElement<?>> result = tuples.get(0).getElements();
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(BigInteger.class, result.get(0).getJavaType());
|
||||
assertEquals("id", result.get(0).getAlias());
|
||||
assertEquals("ID", result.get(0).getAlias());
|
||||
assertEquals(String.class, result.get(1).getJavaType());
|
||||
assertEquals("firstname", result.get(1).getAlias());
|
||||
assertEquals("FIRSTNAME", result.get(1).getAlias());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -706,11 +706,11 @@ public class TupleNativeQueryTest extends BaseEntityManagerFunctionalTestCase {
|
|||
assertEquals(2, result.size());
|
||||
final TupleElement<?> firstTupleElement = result.get(0);
|
||||
assertEquals(BigInteger.class, firstTupleElement.getJavaType());
|
||||
assertEquals("id", firstTupleElement.getAlias());
|
||||
assertEquals("ID", firstTupleElement.getAlias());
|
||||
assertEquals(BigInteger.valueOf(1L), tuple.get(firstTupleElement.getAlias()));
|
||||
final TupleElement<?> secondTupleElement = result.get(1);
|
||||
assertEquals(Object.class, secondTupleElement.getJavaType());
|
||||
assertEquals("firstname", secondTupleElement.getAlias());
|
||||
assertEquals("FIRSTNAME", secondTupleElement.getAlias());
|
||||
assertNull(tuple.get(secondTupleElement.getAlias()));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue