HHH-14826 Fix failure of o.h.test.onetoone.cache.OneToOneCacheTest#OneToOneCacheByForeignKey()

This commit is contained in:
Andrea Boriero 2021-09-17 13:14:39 +02:00 committed by Sanne Grinovero
parent 340b9012d9
commit 5ffed50f1f
1 changed files with 9 additions and 1 deletions

View File

@ -215,11 +215,19 @@ public class OneToOneType extends EntityType {
@Override
public Object assemble(Serializable oid, SharedSessionContractImplementor session, Object owner) throws HibernateException {
if ( oid == null ) {
if ( uniqueKeyPropertyName != null ) {
return resolve( session.getContextEntityIdentifier( owner ), session, owner );
}
return null;
}
//the owner of the association is not the owner of the id
Serializable id = ( Serializable ) getIdentifierType( session ).assemble( oid, session, null );
if ( id == null ) {
return resolve( session.getContextEntityIdentifier(owner), session, owner );
return null;
}
return resolveIdentifier( id, session );