HHH-7808 : Some exceptions returned by LocalBindingContext.makeMappingException() are not thrown
This commit is contained in:
parent
f75c7eff59
commit
58f67d59bd
|
@ -469,7 +469,7 @@ public class Binder {
|
|||
final BasicPluralAttributeElementBinding elementBinding =
|
||||
( BasicPluralAttributeElementBinding ) attributeBinding.getPluralAttributeElementBinding();
|
||||
if ( elementBinding.getNature() != PluralAttributeElementBinding.Nature.BASIC ) {
|
||||
bindingContext().makeMappingException( String.format(
|
||||
throw bindingContext().makeMappingException( String.format(
|
||||
"Expected a SetBinding with an element of nature Nature.BASIC; instead was %s",
|
||||
elementBinding.getNature() ) );
|
||||
}
|
||||
|
@ -1081,7 +1081,7 @@ public class Binder {
|
|||
final String defaultJavaTypeName ) {
|
||||
if ( explicitTypeName == null ) {
|
||||
if ( hibernateTypeDescriptor.getJavaTypeName() != null ) {
|
||||
bindingContext().makeMappingException( String.format(
|
||||
throw bindingContext().makeMappingException( String.format(
|
||||
"Attempt to re-initialize (non-explicit) Java type name; current=%s new=%s",
|
||||
hibernateTypeDescriptor.getJavaTypeName(),
|
||||
defaultJavaTypeName ) );
|
||||
|
@ -1091,7 +1091,7 @@ public class Binder {
|
|||
// Check if user-specified name is of a User-Defined Type (UDT)
|
||||
final TypeDefinition typeDef = metadata.getTypeDefinition( explicitTypeName );
|
||||
if ( hibernateTypeDescriptor.getExplicitTypeName() != null ) {
|
||||
bindingContext().makeMappingException( String.format(
|
||||
throw bindingContext().makeMappingException( String.format(
|
||||
"Attempt to re-initialize explicity-mapped Java type name; current=%s new=%s",
|
||||
hibernateTypeDescriptor.getExplicitTypeName(),
|
||||
explicitTypeName ) );
|
||||
|
@ -1151,7 +1151,7 @@ public class Binder {
|
|||
entityIdentifier.createIdentifierGenerator( identifierGeneratorFactory, properties );
|
||||
if ( IdentityGenerator.class.isInstance( entityIdentifier.getIdentifierGenerator() ) ) {
|
||||
if ( rootEntityBinding.getPrimaryTable().getPrimaryKey().getColumnSpan() != 1 ) {
|
||||
bindingContext().makeMappingException( String.format(
|
||||
throw bindingContext().makeMappingException( String.format(
|
||||
"ID for %s is mapped as an identity with %d columns. IDs mapped as an identity can only have 1 column.",
|
||||
rootEntityBinding.getEntity().getName(),
|
||||
rootEntityBinding.getPrimaryTable().getPrimaryKey().getColumnSpan()
|
||||
|
@ -1978,7 +1978,7 @@ public class Binder {
|
|||
try {
|
||||
attributeBinding.setComparator( comparatorClass.newInstance() );
|
||||
} catch ( Exception error ) {
|
||||
bindingContext().makeMappingException(
|
||||
throw bindingContext().makeMappingException(
|
||||
String.format(
|
||||
"Unable to create comparator [%s] for attribute [%s]",
|
||||
sortable.getComparatorName(),
|
||||
|
@ -2223,7 +2223,7 @@ public class Binder {
|
|||
final boolean isNullableByDefault,
|
||||
final boolean isDefaultAttributeName ) {
|
||||
if ( columnSource.getName() == null && defaultName == null ) {
|
||||
bindingContext().makeMappingException( "Cannot resolve name for column because no name was specified and default name is null." );
|
||||
throw bindingContext().makeMappingException( "Cannot resolve name for column because no name was specified and default name is null." );
|
||||
}
|
||||
final String name;
|
||||
if ( StringHelper.isNotEmpty( columnSource.getName() ) ) {
|
||||
|
@ -2619,7 +2619,7 @@ public class Binder {
|
|||
final EntitySource entitySource = entitySourcesByName.get( entityName );
|
||||
if ( entitySource == null ) {
|
||||
String msg = log.missingEntitySource( entityName );
|
||||
bindingContext().makeMappingException( msg );
|
||||
throw bindingContext().makeMappingException( msg );
|
||||
}
|
||||
|
||||
// Get super entity binding (creating it if necessary using recursive call to this method)
|
||||
|
|
|
@ -399,8 +399,8 @@ public class HibernateTypeHelper {
|
|||
resolvedHibernateType.isEntityType()
|
||||
? EntityType.class.cast( resolvedHibernateType ).getIdentifierOrUniqueKeyType( metadata )
|
||||
: resolvedHibernateType;
|
||||
if ( !ComponentType.class.isInstance( resolvedRelationalType ) ) {
|
||||
binder.bindingContext().makeMappingException( "Column number mismatch" ); // todo refine the exception message
|
||||
if ( !CompositeType.class.isInstance( resolvedRelationalType ) ) {
|
||||
throw binder.bindingContext().makeMappingException( "Column number mismatch" ); // todo refine the exception message
|
||||
}
|
||||
Type[] subTypes = CompositeType.class.cast( resolvedRelationalType ).getSubtypes();
|
||||
for ( int i = 0; i < subTypes.length; i++ ) {
|
||||
|
|
|
@ -320,10 +320,13 @@ public class AssociationAttribute extends MappedAttribute {
|
|||
targetTypeName = targetEntityValue.asClass().name().toString();
|
||||
}
|
||||
|
||||
if( StringHelper.isEmpty( targetTypeName ) && referencedAttributeType!=null ){
|
||||
if( StringHelper.isEmpty( targetTypeName ) ) {
|
||||
if ( referencedAttributeType != null ) {
|
||||
targetTypeName = referencedAttributeType.getName();
|
||||
} else {
|
||||
getContext().makeMappingException( "Can't find the target type for this collection attribute: "+ getRole() );
|
||||
}
|
||||
else {
|
||||
throw getContext().makeMappingException( "Can't find the target type for this collection attribute: "+ getRole() );
|
||||
}
|
||||
}
|
||||
|
||||
return targetTypeName;
|
||||
|
|
Loading…
Reference in New Issue