HHH-16387 Entity in key not returned when querying
This commit is contained in:
parent
bb52619875
commit
947ed23188
|
@ -71,6 +71,8 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
||||||
private Boolean stateAllNull;
|
private Boolean stateAllNull;
|
||||||
private Boolean stateInjected;
|
private Boolean stateInjected;
|
||||||
protected Object compositeInstance;
|
protected Object compositeInstance;
|
||||||
|
private boolean isParentInitialized;
|
||||||
|
private RowProcessingState wrappedProcessingState;
|
||||||
|
|
||||||
public AbstractEmbeddableInitializer(
|
public AbstractEmbeddableInitializer(
|
||||||
EmbeddableResultGraphNode resultDescriptor,
|
EmbeddableResultGraphNode resultDescriptor,
|
||||||
|
@ -207,13 +209,27 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( isParentInitialized ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
stateInjected = false;
|
|
||||||
// We need to possibly wrap the processing state if the embeddable is within an aggregate
|
// We need to possibly wrap the processing state if the embeddable is within an aggregate
|
||||||
processingState = wrapProcessingState( processingState );
|
if ( wrappedProcessingState == null ) {
|
||||||
extractRowState( processingState );
|
wrappedProcessingState = wrapProcessingState( processingState );
|
||||||
prepareCompositeInstance( processingState );
|
}
|
||||||
handleParentInjection( processingState );
|
initializeInstance( );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeInstance() {
|
||||||
|
stateInjected = false;
|
||||||
|
extractRowState( wrappedProcessingState );
|
||||||
|
prepareCompositeInstance( wrappedProcessingState );
|
||||||
|
if ( isParentInitialized ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( !stateInjected ) {
|
||||||
|
handleParentInjection( wrappedProcessingState );
|
||||||
|
}
|
||||||
|
|
||||||
if ( compositeInstance != NULL_MARKER ) {
|
if ( compositeInstance != NULL_MARKER ) {
|
||||||
notifyResolutionListeners( compositeInstance );
|
notifyResolutionListeners( compositeInstance );
|
||||||
|
@ -222,7 +238,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
||||||
// If the composite instance has a lazy initializer attached, this means that the embeddable is actually virtual
|
// If the composite instance has a lazy initializer attached, this means that the embeddable is actually virtual
|
||||||
// and the compositeInstance == entity, so we have to inject the row state into the entity when it finishes resolution
|
// and the compositeInstance == entity, so we have to inject the row state into the entity when it finishes resolution
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
final Initializer parentInitializer = processingState.resolveInitializer( navigablePath.getParent() );
|
final Initializer parentInitializer = wrappedProcessingState.resolveInitializer( navigablePath.getParent() );
|
||||||
if ( parentInitializer != this ) {
|
if ( parentInitializer != this ) {
|
||||||
( (FetchParentAccess) parentInitializer ).registerResolutionListener( (entity) -> {
|
( (FetchParentAccess) parentInitializer ).registerResolutionListener( (entity) -> {
|
||||||
representationEmbeddable.setValues( entity, rowState );
|
representationEmbeddable.setValues( entity, rowState );
|
||||||
|
@ -264,6 +280,11 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
||||||
&& !ForeignKeyDescriptor.TARGET_PART_NAME.equals( navigablePath.getLocalName() ) ) {
|
&& !ForeignKeyDescriptor.TARGET_PART_NAME.equals( navigablePath.getLocalName() ) ) {
|
||||||
fetchParentAccess.resolveInstance( processingState );
|
fetchParentAccess.resolveInstance( processingState );
|
||||||
compositeInstance = fetchParentAccess.getInitializedInstance();
|
compositeInstance = fetchParentAccess.getInitializedInstance();
|
||||||
|
EntityInitializer entityInitializer = fetchParentAccess.asEntityInitializer();
|
||||||
|
if ( entityInitializer != null && entityInitializer.isEntityInitialized() ) {
|
||||||
|
this.isParentInitialized = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( compositeInstance == null ) {
|
if ( compositeInstance == null ) {
|
||||||
|
@ -485,6 +506,8 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
|
||||||
compositeInstance = null;
|
compositeInstance = null;
|
||||||
stateAllNull = null;
|
stateAllNull = null;
|
||||||
stateInjected = null;
|
stateInjected = null;
|
||||||
|
isParentInitialized = false;
|
||||||
|
wrappedProcessingState = null;
|
||||||
|
|
||||||
clearResolutionListeners();
|
clearResolutionListeners();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue