generate sensibly-lengthed columns for UUIDs

Previously, Hibernate generated column definitions of
type 255 for BINARY/CHAR columns that will have UUIDs
stored in them. It should be:

- length 16 for BINARY
- length 36 for CHAR
This commit is contained in:
Gavin King 2020-08-27 21:21:18 +02:00 committed by Andrea Boriero
parent 377ca5c073
commit ab5d350805
2 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,7 @@ package org.hibernate.type;
import java.util.UUID;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.UUIDTypeDescriptor;
import org.hibernate.type.descriptor.sql.BinaryTypeDescriptor;
@ -20,7 +21,12 @@ public class UUIDBinaryType extends AbstractSingleColumnStandardBasicType<UUID>
public static final UUIDBinaryType INSTANCE = new UUIDBinaryType();
public UUIDBinaryType() {
super( BinaryTypeDescriptor.INSTANCE, UUIDTypeDescriptor.INSTANCE );
super( BinaryTypeDescriptor.INSTANCE, new UUIDTypeDescriptor() {
@Override
public long getDefaultSqlLength(Dialect dialect) {
return 16;
}
} );
}
public String getName() {

View File

@ -21,7 +21,12 @@ public class UUIDCharType extends AbstractSingleColumnStandardBasicType<UUID> im
public static final UUIDCharType INSTANCE = new UUIDCharType();
public UUIDCharType() {
super( VarcharTypeDescriptor.INSTANCE, UUIDTypeDescriptor.INSTANCE );
super( VarcharTypeDescriptor.INSTANCE, new UUIDTypeDescriptor() {
@Override
public long getDefaultSqlLength(Dialect dialect) {
return 36;
}
} );
}
public String getName() {