Fix @ForeignKeyey(ConstraintMode.NO_CONSTRAINT) throwing EntityNotFoundException
This commit is contained in:
parent
33a7133695
commit
1a1a6c22f1
|
@ -136,7 +136,7 @@ public class ToOneAttributeMapping
|
|||
hence this flag is also controlling the default join type.
|
||||
*/
|
||||
private final boolean isKeyTableNullable;
|
||||
private final boolean isConstrained;
|
||||
private final boolean isInternalLoadNullable;
|
||||
private final NotFoundAction notFoundAction;
|
||||
private final boolean unwrapProxy;
|
||||
private final boolean isOptional;
|
||||
|
@ -294,6 +294,7 @@ public class ToOneAttributeMapping
|
|||
}
|
||||
}
|
||||
isOptional = ( (ManyToOne) bootValue ).isIgnoreNotFound();
|
||||
isInternalLoadNullable = ( isNullable && bootValue.isForeignKeyEnabled() ) || notFoundAction == NotFoundAction.IGNORE;
|
||||
}
|
||||
else {
|
||||
assert bootValue instanceof OneToOne;
|
||||
|
@ -361,8 +362,8 @@ public class ToOneAttributeMapping
|
|||
notFoundAction = null;
|
||||
isKeyTableNullable = isNullable();
|
||||
isOptional = ! bootValue.isConstrained();
|
||||
isInternalLoadNullable = isNullable();
|
||||
}
|
||||
isConstrained = bootValue.isConstrained();
|
||||
|
||||
this.navigableRole = navigableRole;
|
||||
this.declaringTableGroupProducer = resolveDeclaringTableGroupProducer( declaringEntityPersister );
|
||||
|
@ -529,7 +530,7 @@ public class ToOneAttributeMapping
|
|||
this.cardinality = original.cardinality;
|
||||
this.bidirectionalAttributeName = original.bidirectionalAttributeName;
|
||||
this.declaringTableGroupProducer = declaringTableGroupProducer;
|
||||
this.isConstrained = original.isConstrained;
|
||||
this.isInternalLoadNullable = original.isInternalLoadNullable;
|
||||
}
|
||||
|
||||
private static boolean equal(Value lhsValue, Value rhsValue) {
|
||||
|
@ -1049,8 +1050,8 @@ public class ToOneAttributeMapping
|
|||
&& parentNavigablePath.equals( fetchParent.getNavigablePath().getRealParent() );
|
||||
|
||||
|
||||
if ( hasNotFoundAction()
|
||||
|| ( fetchTiming == FetchTiming.IMMEDIATE && selected ) ) {
|
||||
if ( (hasNotFoundAction()
|
||||
|| ( fetchTiming == FetchTiming.IMMEDIATE && selected )) ) {
|
||||
final TableGroup tableGroup = determineTableGroup(
|
||||
fetchablePath,
|
||||
fetchParent,
|
||||
|
@ -1655,8 +1656,8 @@ public class ToOneAttributeMapping
|
|||
return isOptional;
|
||||
}
|
||||
|
||||
public boolean isConstrained(){
|
||||
return isConstrained;
|
||||
public boolean isInternalLoadNullable() {
|
||||
return isInternalLoadNullable;
|
||||
}
|
||||
|
||||
public NotFoundAction getNotFoundAction() {
|
||||
|
|
|
@ -221,7 +221,7 @@ public class BatchEntitySelectFetchInitializer extends AbstractFetchParentAccess
|
|||
entityKey.getEntityName(),
|
||||
entityKey.getIdentifier(),
|
||||
true,
|
||||
referencedModelPart.isNullable()
|
||||
referencedModelPart.isInternalLoadNullable()
|
||||
);
|
||||
if ( instance != null ) {
|
||||
( (AbstractEntityPersister) referencedModelPart.getDeclaringType() ).setPropertyValue(
|
||||
|
|
|
@ -48,7 +48,6 @@ public class EntitySelectFetchInitializer extends AbstractFetchParentAccess impl
|
|||
protected final DomainResultAssembler<?> keyAssembler;
|
||||
private final ToOneAttributeMapping toOneMapping;
|
||||
|
||||
private Object entityIdentifier;
|
||||
protected boolean isInitialized;
|
||||
|
||||
protected Object entityInstance;
|
||||
|
@ -199,7 +198,7 @@ public class EntitySelectFetchInitializer extends AbstractFetchParentAccess impl
|
|||
entityName,
|
||||
entityIdentifier,
|
||||
true,
|
||||
toOneMapping.isNullable() || toOneMapping.isIgnoreNotFound()
|
||||
toOneMapping.isInternalLoadNullable()
|
||||
);
|
||||
|
||||
if ( entityInstance == null ) {
|
||||
|
@ -241,7 +240,6 @@ public class EntitySelectFetchInitializer extends AbstractFetchParentAccess impl
|
|||
|
||||
@Override
|
||||
public void finishUpRow(RowProcessingState rowProcessingState) {
|
||||
entityIdentifier = null;
|
||||
entityInstance = null;
|
||||
isInitialized = false;
|
||||
clearResolutionListeners();
|
||||
|
|
|
@ -19,10 +19,8 @@ import org.hibernate.annotations.NotFound;
|
|||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.NotImplementedYet;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -133,7 +131,6 @@ public class EagerProxyNotFoundTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@NotImplementedYet( strict = false )
|
||||
public void testExistingProxyWithNonExistingAssociation(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
|
@ -166,7 +163,6 @@ public class EagerProxyNotFoundTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@NotImplementedYet( strict = false )
|
||||
public void testEnityWithNotExistingAssociation(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
|
|
Loading…
Reference in New Issue