Log first Exception when MappingModelCreationProcess cannot complete
This commit is contained in:
parent
da1972ed7b
commit
1f42b9badb
|
@ -114,37 +114,14 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
|
||||
creationProcess.registerInitializationCallback(
|
||||
"EmbeddableMappingType(" + mappingType.getNavigableRole().getFullPath() + ")#finishInitialization",
|
||||
() -> {
|
||||
try {
|
||||
final boolean finished = mappingType.finishInitialization(
|
||||
() ->
|
||||
mappingType.finishInitialization(
|
||||
bootDescriptor,
|
||||
compositeType,
|
||||
rootTableExpression,
|
||||
rootTableKeyColumnNames,
|
||||
creationProcess
|
||||
);
|
||||
|
||||
if ( finished ) {
|
||||
return finished;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
if ( e instanceof NonTransientException ) {
|
||||
throw e;
|
||||
}
|
||||
MappingModelCreationLogger.LOGGER.debugf(
|
||||
e,
|
||||
"(DEBUG) Error finalizing EmbeddableMappingType(%s)",
|
||||
mappingType.getNavigableRole()
|
||||
);
|
||||
}
|
||||
|
||||
MappingModelCreationLogger.LOGGER.debugf(
|
||||
"EmbeddableMappingType(%s) finalization was not able to complete successfully",
|
||||
mappingType.getNavigableRole()
|
||||
);
|
||||
return false;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
return mappingType;
|
||||
|
|
|
@ -125,34 +125,14 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden
|
|||
|
||||
creationProcess.registerInitializationCallback(
|
||||
"IdClassEmbeddable(" + navigableRole.getFullPath() + ")#finishInitialization",
|
||||
() -> {
|
||||
try {
|
||||
final boolean finished = finishInitialization(
|
||||
() ->
|
||||
finishInitialization(
|
||||
idClassSource,
|
||||
idClassType,
|
||||
idTable,
|
||||
idColumns,
|
||||
creationProcess
|
||||
);
|
||||
|
||||
if ( finished ) {
|
||||
return finished;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
MappingModelCreationLogger.LOGGER.debugf(
|
||||
e,
|
||||
"(DEBUG) Error finalizing IdClassEmbeddable(%s)",
|
||||
navigableRole
|
||||
);
|
||||
}
|
||||
|
||||
MappingModelCreationLogger.LOGGER.debugf(
|
||||
"IdClassEmbeddable(%s) finalization was not able to complete successfully",
|
||||
navigableRole
|
||||
);
|
||||
return false;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -779,20 +779,8 @@ public class MappingModelCreationHelper {
|
|||
creationProcess.registerInitializationCallback(
|
||||
"PluralAttributeMapping(" + bootValueMapping.getRole() + ")#finishInitialization",
|
||||
() -> {
|
||||
try {
|
||||
pluralAttributeMapping.finishInitialization( bootProperty, bootValueMapping, creationProcess );
|
||||
return true;
|
||||
}
|
||||
catch (NotYetImplementedFor6Exception nye) {
|
||||
throw nye;
|
||||
}
|
||||
catch (Exception e) {
|
||||
if ( e instanceof NonTransientException ) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
pluralAttributeMapping.finishInitialization( bootProperty, bootValueMapping, creationProcess );
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1378,22 +1366,14 @@ public class MappingModelCreationHelper {
|
|||
creationProcess.registerInitializationCallback(
|
||||
"PluralAttributeMapping( " + bootValueMapping.getRole() + ") - index descriptor",
|
||||
() -> {
|
||||
try {
|
||||
indexDescriptor.finishInitialization(
|
||||
collectionDescriptor,
|
||||
bootValueMapping,
|
||||
indexEntityType.getRHSUniqueKeyPropertyName(),
|
||||
creationProcess
|
||||
);
|
||||
indexDescriptor.finishInitialization(
|
||||
collectionDescriptor,
|
||||
bootValueMapping,
|
||||
indexEntityType.getRHSUniqueKeyPropertyName(),
|
||||
creationProcess
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (NotYetImplementedFor6Exception nye) {
|
||||
throw nye;
|
||||
}
|
||||
catch (Exception wait) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1487,22 +1467,14 @@ public class MappingModelCreationHelper {
|
|||
creationProcess.registerInitializationCallback(
|
||||
"PluralAttributeMapping( " + elementDescriptor.getNavigableRole() + ") - index descriptor",
|
||||
() -> {
|
||||
try {
|
||||
elementDescriptor.finishInitialization(
|
||||
collectionDescriptor,
|
||||
bootDescriptor,
|
||||
elementEntityType.getRHSUniqueKeyPropertyName(),
|
||||
creationProcess
|
||||
);
|
||||
elementDescriptor.finishInitialization(
|
||||
collectionDescriptor,
|
||||
bootDescriptor,
|
||||
elementEntityType.getRHSUniqueKeyPropertyName(),
|
||||
creationProcess
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (NotYetImplementedFor6Exception nye) {
|
||||
throw nye;
|
||||
}
|
||||
catch (Exception wait) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
package org.hibernate.metamodel.mapping.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -92,8 +94,8 @@ public class MappingModelCreationProcess {
|
|||
private void executePostInitCallbacks() {
|
||||
MappingModelCreationLogger.LOGGER.debugf( "Starting post-init callbacks" );
|
||||
|
||||
Map<PostInitCallbackEntry, Exception> exceptions = new HashMap<>();
|
||||
while ( postInitCallbacks != null && !postInitCallbacks.isEmpty() ) {
|
||||
|
||||
// copy to avoid CCME
|
||||
final ArrayList<PostInitCallbackEntry> copy = new ArrayList<>( postInitCallbacks );
|
||||
|
||||
|
@ -108,6 +110,7 @@ public class MappingModelCreationProcess {
|
|||
if ( completed ) {
|
||||
anyCompleted = true;
|
||||
postInitCallbacks.remove( callbackEntry );
|
||||
exceptions.remove( callbackEntry );
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -118,6 +121,7 @@ public class MappingModelCreationProcess {
|
|||
);
|
||||
throw e;
|
||||
}
|
||||
exceptions.put( callbackEntry, e );
|
||||
|
||||
final String format = "Mapping-model creation encountered (possibly) transient error : %s";
|
||||
if ( MappingModelCreationLogger.TRACE_ENABLED ) {
|
||||
|
@ -129,20 +133,23 @@ public class MappingModelCreationProcess {
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! anyCompleted ) {
|
||||
if ( !anyCompleted ) {
|
||||
// none of the remaining callbacks could complete fully, this is an error
|
||||
final StringBuilder buff = new StringBuilder(
|
||||
"PostInitCallback queue could not be processed..."
|
||||
);
|
||||
|
||||
postInitCallbacks.forEach(
|
||||
callbackEntry -> buff.append( EOL )
|
||||
.append( " - " ).append( callbackEntry )
|
||||
);
|
||||
|
||||
buff.append( EOL );
|
||||
|
||||
throw new IllegalStateException( buff.toString() );
|
||||
final IllegalStateException illegalStateException = new IllegalStateException( buff.toString() );
|
||||
|
||||
for ( Map.Entry<PostInitCallbackEntry, Exception> entry : exceptions.entrySet() ) {
|
||||
illegalStateException.addSuppressed( entry.getValue() );
|
||||
}
|
||||
throw illegalStateException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,40 +82,14 @@ public class VirtualIdEmbeddable extends AbstractEmbeddableMapping implements Id
|
|||
|
||||
creationProcess.registerInitializationCallback(
|
||||
"VirtualIdEmbeddable(" + navigableRole.getFullPath() + ")#finishInitialization",
|
||||
() -> {
|
||||
try {
|
||||
final boolean finished = finishInitialization(
|
||||
() ->
|
||||
finishInitialization(
|
||||
virtualIdSource,
|
||||
compositeType,
|
||||
rootTableExpression,
|
||||
rootTableKeyColumnNames,
|
||||
creationProcess
|
||||
);
|
||||
|
||||
if ( finished ) {
|
||||
return finished;
|
||||
}
|
||||
else {
|
||||
MappingModelCreationLogger.LOGGER.debugf(
|
||||
"VirtualIdEmbeddable(%s) finalization was not able to complete successfully",
|
||||
navigableRole.getFullPath()
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
if ( e instanceof NonTransientException ) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
MappingModelCreationLogger.LOGGER.debugf(
|
||||
e,
|
||||
"(DEBUG) Error finalizing VirtualIdEmbeddable(%s)",
|
||||
navigableRole.getFullPath()
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -5588,15 +5588,10 @@ public abstract class AbstractEntityPersister
|
|||
creationProcess.registerInitializationCallback(
|
||||
"Entity(" + getEntityName() + ") `sqmMultiTableMutationStrategy` interpretation",
|
||||
() -> {
|
||||
try {
|
||||
sqmMultiTableMutationStrategy = interpretSqmMultiTableStrategy(
|
||||
this,
|
||||
creationProcess
|
||||
);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
sqmMultiTableMutationStrategy = interpretSqmMultiTableStrategy(
|
||||
this,
|
||||
creationProcess
|
||||
);
|
||||
if ( sqmMultiTableMutationStrategy == null ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -5626,15 +5621,10 @@ public abstract class AbstractEntityPersister
|
|||
creationProcess.registerInitializationCallback(
|
||||
"Entity(" + getEntityName() + ") `sqmMultiTableInsertStrategy` interpretation",
|
||||
() -> {
|
||||
try {
|
||||
sqmMultiTableInsertStrategy = interpretSqmMultiTableInsertStrategy(
|
||||
this,
|
||||
creationProcess
|
||||
);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
sqmMultiTableInsertStrategy = interpretSqmMultiTableInsertStrategy(
|
||||
this,
|
||||
creationProcess
|
||||
);
|
||||
if ( sqmMultiTableInsertStrategy == null ) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue