HHH-15097 Report VARCHAR as recommended type for UUID to fix issues with AttributeConverters

This commit is contained in:
Christian Beikov 2022-03-08 18:29:02 +01:00
parent c5e95e5a34
commit 48d3da61e7
1 changed files with 8 additions and 0 deletions

View File

@ -7,10 +7,13 @@
package org.hibernate.type.descriptor.java; package org.hibernate.type.descriptor.java;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Types;
import java.util.UUID; import java.util.UUID;
import org.hibernate.internal.util.BytesHelper; import org.hibernate.internal.util.BytesHelper;
import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.spi.JdbcRecommendedSqlTypeMappingContext;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
/** /**
* Descriptor for {@link UUID} handling. * Descriptor for {@link UUID} handling.
@ -32,6 +35,11 @@ public class UUIDTypeDescriptor extends AbstractTypeDescriptor<UUID> {
return ToStringTransformer.INSTANCE.parse( string ); return ToStringTransformer.INSTANCE.parse( string );
} }
@Override
public SqlTypeDescriptor getJdbcRecommendedSqlType(JdbcRecommendedSqlTypeMappingContext context) {
return context.getTypeConfiguration().getSqlTypeDescriptorRegistry().getDescriptor( Types.VARCHAR );
}
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked" })
public <X> X unwrap(UUID value, Class<X> type, WrapperOptions options) { public <X> X unwrap(UUID value, Class<X> type, WrapperOptions options) {
if ( value == null ) { if ( value == null ) {