HHH-17859, HHH-17858 redisable cast to UUID

but leave a comment
This commit is contained in:
Gavin King 2024-03-17 10:49:41 +01:00
parent c60dab34d0
commit ba442f5d18
2 changed files with 6 additions and 3 deletions

View File

@ -347,13 +347,16 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
case "duration": return getBasicTypeForJavaType( Duration.class ); case "duration": return getBasicTypeForJavaType( Duration.class );
case "instant": return getBasicTypeForJavaType( Instant.class ); case "instant": return getBasicTypeForJavaType( Instant.class );
case "binary": return getBasicTypeForJavaType( byte[].class ); case "binary": return getBasicTypeForJavaType( byte[].class );
case "uuid": return getBasicTypeForJavaType( UUID.class );
//this one is very fragile ... works well for BIT or BOOLEAN columns only //this one is very fragile ... works well for BIT or BOOLEAN columns only
//works OK, I suppose, for integer columns, but not at all for char columns //works OK, I suppose, for integer columns, but not at all for char columns
case "boolean": return getBasicTypeForJavaType( Boolean.class ); case "boolean": return getBasicTypeForJavaType( Boolean.class );
case "truefalse": return basicTypeRegistry.getRegisteredType( StandardBasicTypes.TRUE_FALSE.getName() ); case "truefalse": return basicTypeRegistry.getRegisteredType( StandardBasicTypes.TRUE_FALSE.getName() );
case "yesno": return basicTypeRegistry.getRegisteredType( StandardBasicTypes.YES_NO.getName() ); case "yesno": return basicTypeRegistry.getRegisteredType( StandardBasicTypes.YES_NO.getName() );
case "numericboolean": return basicTypeRegistry.getRegisteredType( StandardBasicTypes.NUMERIC_BOOLEAN.getName() ); case "numericboolean": return basicTypeRegistry.getRegisteredType( StandardBasicTypes.NUMERIC_BOOLEAN.getName() );
//really not sure about this one - it works well for casting from binary
//to UUID, but people will want to use it to cast from varchar, and that
//won't work at all without some special casing in the Dialects
// case "uuid": return getBasicTypeForJavaType( UUID.class );
default: { default: {
final BasicType<?> registeredBasicType = basicTypeRegistry.getRegisteredType( name ); final BasicType<?> registeredBasicType = basicTypeRegistry.getRegisteredType( name );
if ( registeredBasicType != null ) { if ( registeredBasicType != null ) {

View File

@ -2293,8 +2293,8 @@ public class FunctionTests {
scope.inTransaction(s -> { scope.inTransaction(s -> {
byte[] bytes = s.createSelectionQuery("select column(e.theuuid as binary) from EntityOfBasics e", byte[].class) byte[] bytes = s.createSelectionQuery("select column(e.theuuid as binary) from EntityOfBasics e", byte[].class)
.getSingleResultOrNull(); .getSingleResultOrNull();
UUID uuid = s.createSelectionQuery("select column(e.theuuid as UUID) from EntityOfBasics e", UUID.class) // UUID uuid = s.createSelectionQuery("select column(e.theuuid as UUID) from EntityOfBasics e", UUID.class)
.getSingleResultOrNull(); // .getSingleResultOrNull();
}); });
} }