get rid of TruthValue and use Boolean

clean it up a bit
This commit is contained in:
Gavin King 2024-11-14 09:58:21 +01:00
parent 424460af3f
commit 26cd62ff6d
17 changed files with 82 additions and 178 deletions

View File

@ -1,40 +0,0 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.boot.model;
/**
* An enumeration of truth values.
*
* @implNote Sure, this could be handled with {@code Boolean}, but
* that option is vulnerable to unwanted auto-unboxing
* and {@link NullPointerException}s.
*
* @author Steve Ebersole
*/
public enum TruthValue {
TRUE,
FALSE,
UNKNOWN;
public static TruthValue of(boolean bool) {
return bool ? TRUE : FALSE;
}
public boolean toBoolean(boolean defaultValue) {
return switch ( this ) {
case TRUE -> true;
case FALSE -> false;
default -> defaultValue;
};
}
/**
* @deprecated No longer used
*/
@Deprecated(since = "7", forRemoval = true)
public static boolean toBoolean(TruthValue value, boolean defaultValue) {
return value != null ? value.toBoolean( defaultValue ) : defaultValue;
}
}

View File

@ -22,7 +22,6 @@ import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSecondaryTableType;
import org.hibernate.boot.jaxb.hbm.spi.SecondaryTableContainer;
import org.hibernate.boot.model.CustomSql;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.source.spi.AttributePath;
import org.hibernate.boot.model.source.spi.AttributeRole;
import org.hibernate.boot.model.source.spi.AttributeSource;
@ -391,10 +390,4 @@ public abstract class AbstractEntitySourceImpl
return jaxbEntityMapping.getSqlQuery();
}
@Override
public TruthValue quoteIdentifiersLocalToEntity() {
// HBM does not allow for this
return TruthValue.UNKNOWN;
}
}

View File

@ -6,7 +6,6 @@ package org.hibernate.boot.model.source.internal.hbm;
import java.util.Set;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.source.spi.ColumnSource;
import org.hibernate.boot.model.source.spi.JdbcDataType;
import org.hibernate.boot.model.source.spi.SizeSource;
@ -24,8 +23,8 @@ class ColumnAttributeSourceImpl
private final String tableName;
private final String columnName;
private final SizeSource sizeSource;
private final TruthValue nullable;
private final TruthValue unique;
private final Boolean nullable;
private final Boolean unique;
private final Set<String> indexConstraintNames;
private final Set<String> ukConstraintNames;
@ -34,8 +33,8 @@ class ColumnAttributeSourceImpl
String tableName,
String columnName,
SizeSource sizeSource,
TruthValue nullable,
TruthValue unique,
Boolean nullable,
Boolean unique,
Set<String> indexConstraintNames,
Set<String> ukConstraintNames) {
super( mappingDocument );
@ -64,7 +63,7 @@ class ColumnAttributeSourceImpl
}
@Override
public TruthValue isNullable() {
public Boolean isNullable() {
return nullable;
}
@ -100,7 +99,7 @@ class ColumnAttributeSourceImpl
@Override
public boolean isUnique() {
return unique == TruthValue.TRUE;
return unique == Boolean.TRUE;
}
@Override

View File

@ -5,16 +5,15 @@
package org.hibernate.boot.model.source.internal.hbm;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmColumnType;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.source.spi.ColumnSource;
import org.hibernate.boot.model.source.spi.JdbcDataType;
import org.hibernate.boot.model.source.spi.SizeSource;
import static java.util.Collections.addAll;
import static org.hibernate.internal.util.StringHelper.splitAtCommas;
/**
@ -25,7 +24,7 @@ class ColumnSourceImpl
implements ColumnSource {
private final String tableName;
private final JaxbHbmColumnType columnElement;
private final TruthValue nullable;
private final Boolean nullable;
private final Set<String> indexConstraintNames;
private final Set<String> ukConstraintNames;
@ -39,27 +38,19 @@ class ColumnSourceImpl
mappingDocument,
tableName,
columnElement,
interpretNotNullToNullability( columnElement.isNotNull() ),
columnElement.isNotNull() == null
? null
: !columnElement.isNotNull(),
indexConstraintNames,
ukConstraintNames
);
}
private static TruthValue interpretNotNullToNullability(Boolean notNull) {
if ( notNull == null ) {
return TruthValue.UNKNOWN;
}
else {
// not-null == nullable, so the booleans are reversed
return notNull ? TruthValue.FALSE : TruthValue.TRUE;
}
}
ColumnSourceImpl(
MappingDocument mappingDocument,
String tableName,
JaxbHbmColumnType columnElement,
TruthValue nullable,
Boolean nullable,
Set<String> indexConstraintNames,
Set<String> ukConstraintNames) {
super( mappingDocument );
@ -86,7 +77,7 @@ class ColumnSourceImpl
}
@Override
public TruthValue isNullable() {
public Boolean isNullable() {
return nullable;
}
@ -126,8 +117,8 @@ class ColumnSourceImpl
@Override
public boolean isUnique() {
// TODO: should TruthValue be returned instead of boolean?
return columnElement.isUnique() != null && columnElement.isUnique().booleanValue();
return columnElement.isUnique() != null
&& columnElement.isUnique();
}
@Override
@ -160,8 +151,8 @@ class ColumnSourceImpl
return stringSet;
}
else {
HashSet<String> set = new HashSet<>( stringSet );
Collections.addAll( set, splitAtCommas( values ) );
final HashSet<String> set = new HashSet<>( stringSet );
addAll( set, splitAtCommas( values ) );
return set;
}
}

View File

@ -7,7 +7,6 @@ package org.hibernate.boot.model.source.internal.hbm;
import java.util.Collections;
import java.util.List;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.relational.Database;
@ -150,7 +149,8 @@ public class RelationalObjectBinder {
}
}
column.setNullable( interpretNullability( columnSource.isNullable(), areColumnsNullableByDefault ) );
final Boolean nullable = columnSource.isNullable();
column.setNullable( nullable == null ? areColumnsNullableByDefault : nullable );
column.setUnique( columnSource.isUnique() );
if ( columnSource.isUnique() && table != null ) {
@ -182,15 +182,6 @@ public class RelationalObjectBinder {
}
}
private static boolean interpretNullability(TruthValue nullable, boolean areColumnsNullableByDefault) {
if ( nullable == null || nullable == TruthValue.UNKNOWN ) {
return areColumnsNullableByDefault;
}
else {
return nullable == TruthValue.TRUE;
}
}
public void bindFormulas(
MappingDocument sourceDocument,
List<DerivedValueSource> formulaSources,

View File

@ -12,14 +12,14 @@ import java.util.Set;
import org.hibernate.boot.MappingException;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmColumnType;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.source.spi.ColumnSource;
import org.hibernate.boot.model.source.spi.DerivedValueSource;
import org.hibernate.boot.model.source.spi.RelationalValueSource;
import org.hibernate.boot.model.source.spi.SizeSource;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
/**
* @author Steve Ebersole
*/
@ -152,7 +152,7 @@ public class RelationalValueSourceHelper {
if ( sources.size() > 1 ) {
final String errorMessage;
if ( columnsAndFormulasSource.getSourceType().canBeNamed()
&& StringHelper.isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
&& isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
errorMessage = String.format(
Locale.ENGLISH,
"Expecting just a single formula/column in context of <%s name=\"%s\"/>",
@ -197,7 +197,7 @@ public class RelationalValueSourceHelper {
if ( sources.size() > 1 ) {
final String errorMessage;
if ( columnsAndFormulasSource.getSourceType().canBeNamed()
&& StringHelper.isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
&& isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
errorMessage = String.format(
Locale.ENGLISH,
"Expecting just a single formula/column in context of <%s name=\"%s\"/>",
@ -219,7 +219,7 @@ public class RelationalValueSourceHelper {
if ( !(result instanceof ColumnSource) ) {
final String errorMessage;
if ( columnsAndFormulasSource.getSourceType().canBeNamed()
&& StringHelper.isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
&& isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
errorMessage = String.format(
Locale.ENGLISH,
"Expecting single column in context of <%s name=\"%s\"/>, but found formula [%s]",
@ -267,7 +267,7 @@ public class RelationalValueSourceHelper {
if ( !(source instanceof ColumnSource) ) {
final String errorMessage;
if ( columnsAndFormulasSource.getSourceType().canBeNamed()
&& StringHelper.isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
&& isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
errorMessage = String.format(
Locale.ENGLISH,
"Expecting only columns in context of <%s name=\"%s\"/>, but found formula [%s]",
@ -307,7 +307,7 @@ public class RelationalValueSourceHelper {
ColumnsAndFormulasSource columnsAndFormulasSource) {
List<RelationalValueSource> result = new ArrayList<>();
if ( StringHelper.isNotEmpty( columnsAndFormulasSource.getFormulaAttribute() ) ) {
if ( isNotEmpty( columnsAndFormulasSource.getFormulaAttribute() ) ) {
// we have an explicit formula attribute (i.e., <SOMETHING formula="abc"/>)
validateUseOfFormulaAttribute( mappingDocument, columnsAndFormulasSource );
@ -359,8 +359,8 @@ public class RelationalValueSourceHelper {
containingTableName,
columnsAndFormulasSource.getColumnAttribute(),
columnsAndFormulasSource.getSizeSource(),
interpretNullabilityToTruthValue( columnsAndFormulasSource.isNullable() ),
columnsAndFormulasSource.isUnique() ? TruthValue.TRUE : TruthValue.FALSE,
columnsAndFormulasSource.isNullable(),
columnsAndFormulasSource.isUnique(),
columnsAndFormulasSource.getIndexConstraintNames(),
columnsAndFormulasSource.getUniqueKeyConstraintNames()
)
@ -370,23 +370,14 @@ public class RelationalValueSourceHelper {
return result;
}
private static TruthValue interpretNullabilityToTruthValue(Boolean nullable) {
if ( nullable == null ) {
return TruthValue.UNKNOWN;
}
else {
return nullable ? TruthValue.TRUE : TruthValue.FALSE;
}
}
private static void validateUseOfFormulaAttribute(
MappingDocument sourceDocument,
ColumnsAndFormulasSource columnsAndFormulasSource) {
// 1) make sure there is no column attribute
if ( StringHelper.isNotEmpty( columnsAndFormulasSource.getColumnAttribute() ) ) {
if ( isNotEmpty( columnsAndFormulasSource.getColumnAttribute() ) ) {
final String errorMessage;
if ( columnsAndFormulasSource.getSourceType().canBeNamed()
&& StringHelper.isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
&& isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
errorMessage = String.format(
Locale.ENGLISH,
"column attribute and formula attribute may not be specified together near <%s name=\"%s\" column=\"%s\" formula=\"%s\" />",
@ -411,7 +402,7 @@ public class RelationalValueSourceHelper {
if ( CollectionHelper.isNotEmpty( columnsAndFormulasSource.getColumnOrFormulaElements() ) ) {
final String errorMessage;
if ( columnsAndFormulasSource.getSourceType().canBeNamed()
&& StringHelper.isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
&& isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
errorMessage = String.format(
Locale.ENGLISH,
"formula attribute may not be specified along with <column/> or <formula/> subelement(s) near <%s name=\"%s\" formula=\"%s\" />",
@ -435,10 +426,10 @@ public class RelationalValueSourceHelper {
private static void validateUseOfColumnOrFormulaNestedElements(
MappingDocument sourceDocument,
ColumnsAndFormulasSource columnsAndFormulasSource) {
if ( StringHelper.isNotEmpty( columnsAndFormulasSource.getColumnAttribute() ) ) {
if ( isNotEmpty( columnsAndFormulasSource.getColumnAttribute() ) ) {
final String errorMessage;
if ( columnsAndFormulasSource.getSourceType().canBeNamed()
&& StringHelper.isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
&& isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
errorMessage = String.format(
Locale.ENGLISH,
"column attribute may not be specified along with <column/> or <formula/> subelement(s) near <%s name=\"%s\" column=\"%s\" />",
@ -467,7 +458,7 @@ public class RelationalValueSourceHelper {
if ( customWrite != null && !customWrite.matches("[^?]*\\?[^?]*") ) {
final String errorMessage;
if ( columnsAndFormulasSource.getSourceType().canBeNamed()
&& StringHelper.isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
&& isNotEmpty( columnsAndFormulasSource.getSourceName() ) ) {
errorMessage = String.format(
Locale.ENGLISH,
"write expression must contain exactly one value placeholder ('?') character near <column name=\"%s\" ... write=\"%s\" /> for <%s name=\"%s\" />",

View File

@ -5,7 +5,6 @@
package org.hibernate.boot.model.source.spi;
import org.hibernate.boot.CacheRegionDefinition;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.cache.spi.access.AccessType;
import static org.hibernate.internal.util.StringHelper.isEmpty;
@ -17,25 +16,21 @@ import static org.hibernate.internal.util.StringHelper.isEmpty;
* @author Hardy Ferentschik
*/
public class Caching {
// NOTE : TruthValue for now because I need to look at how JPA's SharedCacheMode concept is handled
private TruthValue requested;
private Boolean requested;
private String region;
private AccessType accessType;
private boolean cacheLazyProperties;
public Caching() {
this.requested = TruthValue.UNKNOWN;
}
public Caching() {}
public Caching(String region, AccessType accessType, boolean cacheLazyProperties) {
this.requested = TruthValue.UNKNOWN;
this.region = region;
this.accessType = accessType;
this.cacheLazyProperties = cacheLazyProperties;
}
public Caching(String region, AccessType accessType, boolean cacheLazyProperties, boolean requested) {
this.requested = TruthValue.of( requested );
this.requested = requested;
this.region = region;
this.accessType = accessType;
this.cacheLazyProperties = cacheLazyProperties;
@ -66,20 +61,20 @@ public class Caching {
}
public boolean isRequested() {
return requested == TruthValue.TRUE;
return requested == Boolean.TRUE;
}
public boolean isRequested(boolean defaultValue) {
return requested == TruthValue.UNKNOWN ? defaultValue : isRequested();
return requested == null ? defaultValue : isRequested();
}
public void setRequested(boolean requested) {
this.requested = TruthValue.of(requested);
this.requested = requested;
}
public void overlay(CacheRegionDefinition overrides) {
if ( overrides != null ) {
requested = TruthValue.TRUE;
requested = true;
accessType = AccessType.fromExternalName( overrides.getUsage() );
if ( isEmpty( overrides.getRegion() ) ) {
region = overrides.getRegion();
@ -105,5 +100,4 @@ public class Caching {
+ ", cacheLazyProperties=" + cacheLazyProperties
+ ", requested=" + requested + '}';
}
}

View File

@ -6,8 +6,6 @@ package org.hibernate.boot.model.source.spi;
import java.util.Set;
import org.hibernate.boot.model.TruthValue;
/**
* Contract for source information pertaining to a physical column definition specific to a particular attribute
* context.
@ -44,7 +42,7 @@ public interface ColumnSource extends RelationalValueSource {
*
* @return {@code true} indicates it is nullable; {@code false} non-nullable.
*/
TruthValue isNullable();
Boolean isNullable();
/**
* Obtain a specified default value for the column

View File

@ -10,7 +10,6 @@ import java.util.Map;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedNativeQueryType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedQueryType;
import org.hibernate.boot.model.CustomSql;
import org.hibernate.boot.model.TruthValue;
/**
* Contract describing source of information related to mapping an entity.
@ -146,7 +145,4 @@ public interface EntitySource extends IdentifiableTypeSource, ToolingHintContext
List<JaxbHbmNamedQueryType> getNamedQueries();
List<JaxbHbmNamedNativeQueryType> getNamedNativeQueries();
TruthValue quoteIdentifiersLocalToEntity();
}

View File

@ -14,7 +14,6 @@ import org.hibernate.AssertionFailure;
import org.hibernate.Internal;
import org.hibernate.MappingException;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.spi.MetadataBuildingContext;
@ -435,8 +434,8 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
}
@Override
public TruthValue getNullable() {
return nullable ? TruthValue.TRUE : TruthValue.FALSE;
public Boolean getNullable() {
return nullable;
}
@Override

View File

@ -18,7 +18,6 @@ import java.util.Objects;
import java.util.StringTokenizer;
import org.hibernate.JDBCException;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.naming.DatabaseIdentifier;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.QualifiedTableName;
@ -50,7 +49,7 @@ public abstract class AbstractInformationExtractorImpl implements InformationExt
private final String[] tableTypes;
private String[] extraPhysicalTableTypes;
private final String[] extraPhysicalTableTypes;
private final ExtractionContext extractionContext;
@ -430,8 +429,8 @@ public abstract class AbstractInformationExtractorImpl implements InformationExt
.getIdentifierHelper()
.toIdentifier( extractionContext.getJdbcConnection().getSchema() );
}
catch (SQLException ignore) {
LOG.sqlWarning( ignore.getErrorCode(), ignore.getSQLState() );
catch (SQLException sqle) {
LOG.sqlWarning( sqle.getErrorCode(), sqle.getSQLState() );
}
catch (AbstractMethodError ignore) {
// jConnect and jTDS report that they "support" schemas, but they don't really
@ -911,25 +910,24 @@ public abstract class AbstractInformationExtractorImpl implements InformationExt
}
}
protected TruthValue interpretNullable(int nullable) {
switch ( nullable ) {
case ResultSetMetaData.columnNullable:
return TruthValue.TRUE;
case ResultSetMetaData.columnNoNulls:
return TruthValue.FALSE;
default:
return TruthValue.UNKNOWN;
}
protected Boolean interpretNullable(int nullable) {
return switch ( nullable ) {
case ResultSetMetaData.columnNullable -> Boolean.TRUE;
case ResultSetMetaData.columnNoNulls -> Boolean.FALSE;
default -> null;
};
}
private TruthValue interpretTruthValue(String nullable) {
private Boolean interpretTruthValue(String nullable) {
if ( "yes".equalsIgnoreCase( nullable ) ) {
return TruthValue.TRUE;
return Boolean.TRUE;
}
else if ( "no".equalsIgnoreCase( nullable ) ) {
return TruthValue.FALSE;
return Boolean.FALSE;
}
else {
return null;
}
return TruthValue.UNKNOWN;
}
// This method is not currently used.

View File

@ -4,7 +4,6 @@
*/
package org.hibernate.tool.schema.extract.internal;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.tool.schema.extract.spi.ColumnInformation;
import org.hibernate.tool.schema.extract.spi.TableInformation;
@ -23,7 +22,7 @@ public class ColumnInformationImpl implements ColumnInformation {
private final String typeName;
private final int columnSize;
private final int decimalDigits;
private final TruthValue nullable;
private final Boolean nullable;
public ColumnInformationImpl(
TableInformation containingTableInformation,
@ -32,7 +31,7 @@ public class ColumnInformationImpl implements ColumnInformation {
String typeName,
int columnSize,
int decimalDigits,
TruthValue nullable) {
Boolean nullable) {
this.containingTableInformation = containingTableInformation;
this.columnIdentifier = columnIdentifier;
this.typeCode = typeCode;
@ -73,7 +72,7 @@ public class ColumnInformationImpl implements ColumnInformation {
}
@Override
public TruthValue getNullable() {
public Boolean getNullable() {
return nullable;
}

View File

@ -4,7 +4,6 @@
*/
package org.hibernate.tool.schema.extract.spi;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.naming.Identifier;
/**
@ -29,11 +28,13 @@ public interface ColumnInformation extends ColumnTypeInformation {
Identifier getColumnIdentifier();
/**
* Is the column nullable. The database is allowed to report unknown, hence the use of TruthValue
* Is the column nullable.
* <p>
* The database is allowed to report unknown, hence the use of {@link Boolean}.
*
* @return nullability.
* @return nullability, if known
*/
TruthValue getNullable();
Boolean getNullable();
/**
* The JDBC type-code.

View File

@ -7,7 +7,6 @@ package org.hibernate.tool.schema.extract.spi;
import java.sql.Types;
import org.hibernate.Incubating;
import org.hibernate.boot.model.TruthValue;
/**
* Provides access to information about existing table columns
@ -20,8 +19,8 @@ public interface ColumnTypeInformation {
ColumnTypeInformation EMPTY = new ColumnTypeInformation() {
@Override
public TruthValue getNullable() {
return TruthValue.UNKNOWN;
public Boolean getNullable() {
return null;
}
@Override
@ -46,11 +45,13 @@ public interface ColumnTypeInformation {
};
/**
* Is the column nullable. The database is allowed to report unknown, hence the use of TruthValue
* Is the column nullable.
* <p>
* The database is allowed to report unknown, hence the use of {@link Boolean}.
*
* @return nullability.
* @return nullability, if known
*/
TruthValue getNullable();
Boolean getNullable();
/**
* The JDBC type-code.

View File

@ -10,7 +10,6 @@ import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.dialect.Dialect;
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
@ -165,7 +164,7 @@ public class JdbcTypeRegistry implements JdbcTypeBaseline.BaselineTarget, Serial
registrationKey = null;
}
final JdbcType descriptor = getDescriptor( jdbcTypeCode );
if ( !( descriptor instanceof AggregateJdbcType ) ) {
if ( !(descriptor instanceof AggregateJdbcType aggregateJdbcType) ) {
throw new IllegalArgumentException(
String.format(
"Tried to resolve the JdbcType [%s] as AggregateJdbcType but it does not implement that interface!",
@ -173,7 +172,6 @@ public class JdbcTypeRegistry implements JdbcTypeBaseline.BaselineTarget, Serial
)
);
}
final AggregateJdbcType aggregateJdbcType = (AggregateJdbcType) descriptor;
final AggregateJdbcType resolvedJdbcType = aggregateJdbcType.resolveAggregateJdbcType(
embeddableMappingType,
typeName,
@ -181,8 +179,7 @@ public class JdbcTypeRegistry implements JdbcTypeBaseline.BaselineTarget, Serial
);
if ( registrationKey != null ) {
aggregateDescriptorMap.put( registrationKey, resolvedJdbcType );
if ( resolvedJdbcType instanceof SqlTypedJdbcType ) {
final SqlTypedJdbcType sqlTypedJdbcType = (SqlTypedJdbcType) resolvedJdbcType;
if ( resolvedJdbcType instanceof SqlTypedJdbcType sqlTypedJdbcType ) {
sqlTypedDescriptorMap.put( sqlTypedJdbcType.getSqlTypeName().toLowerCase( Locale.ROOT ), sqlTypedJdbcType );
}
}
@ -295,7 +292,7 @@ public class JdbcTypeRegistry implements JdbcTypeBaseline.BaselineTarget, Serial
private static final class TypeConstructedJdbcTypeKey {
private final int typeConstructorTypeCode;
private final Object jdbcTypeOrBasicType;
private final TruthValue nullable;
private final Boolean nullable;
private final int typeCode;
private final @Nullable String typeName;
private final int columnSize;
@ -308,7 +305,7 @@ public class JdbcTypeRegistry implements JdbcTypeBaseline.BaselineTarget, Serial
this.typeConstructorTypeCode = typeConstructorTypeCode;
this.jdbcTypeOrBasicType = jdbcTypeOrBasicType;
if ( columnTypeInformation == null ) {
this.nullable = TruthValue.UNKNOWN;
this.nullable = null;
this.typeCode = Types.OTHER;
this.typeName = null;
this.columnSize = 0;

View File

@ -11,7 +11,6 @@ import java.util.List;
import java.util.Set;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.Namespace;
import org.hibernate.boot.model.relational.Namespace.Name;
@ -362,9 +361,7 @@ public class CheckForExistingForeignKeyTest {
String typeName = null;
int columnSize = 0;
int decimalDigits = 0;
TruthValue nullable = null;
ColumnInformationImpl columnInformation = new ColumnInformationImpl( containingTableInformation, columnIdentifier, typeCode, typeName, columnSize,
decimalDigits, nullable );
return columnInformation;
return new ColumnInformationImpl( containingTableInformation, columnIdentifier, typeCode, typeName, columnSize,
decimalDigits, null );
}
}

View File

@ -8,7 +8,6 @@ import java.util.ArrayList;
import java.util.Set;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.Namespace;
import org.hibernate.boot.model.relational.QualifiedTableName;
@ -62,8 +61,8 @@ public class AbstractSchemaMigratorTest {
.when(destinationTableInformation).getName();
columnReferenceMappings.add(new ForeignKeyInformationImpl.ColumnReferenceMappingImpl(
new ColumnInformationImpl(null, toIdentifier("referencing_column"), // column name is lower case
0, "typeName", 255, 0, TruthValue.TRUE),
new ColumnInformationImpl(destinationTableInformation, null, 1, "typeName", 0, 0, TruthValue.TRUE)));
0, "typeName", 255, 0, true),
new ColumnInformationImpl(destinationTableInformation, null, 1, "typeName", 0, 0, true)));
doReturn(singletonList(new ForeignKeyInformationImpl(toIdentifier("FKp8mpamfw2inhj88hwhty1eipm"), columnReferenceMappings)))
.when(existingTableInformation).getForeignKeys();