very minor code changes to ForeignGenerator
This commit is contained in:
parent
78cd0175cc
commit
d1db92c220
|
@ -87,11 +87,10 @@ public class ForeignGenerator implements IdentifierGenerator, StandardGenerator
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object generate(SharedSessionContractImplementor sessionImplementor, Object object) {
|
public Object generate(SharedSessionContractImplementor sessionImplementor, Object object) {
|
||||||
final EntityPersister entityDescriptor = sessionImplementor.getFactory()
|
final EntityPersister entityDescriptor =
|
||||||
.getRuntimeMetamodels()
|
sessionImplementor.getFactory().getMappingMetamodel()
|
||||||
.getMappingMetamodel()
|
.getEntityDescriptor( entityName );
|
||||||
.getEntityDescriptor( entityName );
|
final Object associatedObject = entityDescriptor.getPropertyValue( object, propertyName );
|
||||||
Object associatedObject = entityDescriptor.getPropertyValue( object, propertyName );
|
|
||||||
if ( associatedObject == null ) {
|
if ( associatedObject == null ) {
|
||||||
throw new IdentifierGenerationException(
|
throw new IdentifierGenerationException(
|
||||||
"attempted to assign id from null one-to-one property [" + getRole() + "]"
|
"attempted to assign id from null one-to-one property [" + getRole() + "]"
|
||||||
|
@ -111,7 +110,7 @@ public class ForeignGenerator implements IdentifierGenerator, StandardGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
Object id;
|
Object id;
|
||||||
String associatedEntityName = foreignValueSourceType.getAssociatedEntityName();
|
final String associatedEntityName = foreignValueSourceType.getAssociatedEntityName();
|
||||||
try {
|
try {
|
||||||
id = getEntityIdentifierIfNotUnsaved( associatedEntityName, associatedObject, sessionImplementor );
|
id = getEntityIdentifierIfNotUnsaved( associatedEntityName, associatedObject, sessionImplementor );
|
||||||
}
|
}
|
||||||
|
@ -133,7 +132,8 @@ public class ForeignGenerator implements IdentifierGenerator, StandardGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sessionImplementor.isSessionImplementor() && sessionImplementor.asSessionImplementor().contains( entityName, object ) ) {
|
if ( sessionImplementor.isSessionImplementor()
|
||||||
|
&& sessionImplementor.asSessionImplementor().contains( entityName, object ) ) {
|
||||||
//abort the save (the object is already saved by a circular cascade)
|
//abort the save (the object is already saved by a circular cascade)
|
||||||
return SHORT_CIRCUIT_INDICATOR;
|
return SHORT_CIRCUIT_INDICATOR;
|
||||||
//throw new IdentifierGenerationException("save associated object first, or disable cascade for inverse association");
|
//throw new IdentifierGenerationException("save associated object first, or disable cascade for inverse association");
|
||||||
|
|
Loading…
Reference in New Issue