HHH-15045 + HHH-15235 onFlushDirty() invoked on parent entity in a @OneToOne relationship when no table columns are changed - PropertyAccessException on merging Bidirectional OneToOne with EmbeddedId - Reverted HHH-14216
This commit is contained in:
parent
914a2c561b
commit
f935eb2430
|
@ -385,7 +385,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
|||
/**
|
||||
* Resolve an identifier or unique key value
|
||||
*/
|
||||
private Object resolve(Object value, SharedSessionContractImplementor session, Object owner) {
|
||||
protected Object resolve(Object value, SharedSessionContractImplementor session, Object owner) {
|
||||
if ( value != null && !isNull( owner, session ) ) {
|
||||
if ( isReferenceToPrimaryKey() ) {
|
||||
return resolveIdentifier( value, session, null );
|
||||
|
|
|
@ -106,17 +106,12 @@ public class OneToOneType extends EntityType {
|
|||
|
||||
@Override
|
||||
public boolean isDirty(Object old, Object current, SharedSessionContractImplementor session) {
|
||||
if ( isSame( old, current ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getIdentifierType( session )
|
||||
.isDirty( getIdentifier( old, session ), getIdentifier( current, session ), session );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty(Object old, Object current, boolean[] checkable, SharedSessionContractImplementor session) {
|
||||
return isDirty(old, current, session);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,37 +136,25 @@ public class OneToOneType extends EntityType {
|
|||
|
||||
@Override
|
||||
public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Object id = ForeignKeys.getEntityIdentifierIfNotUnsaved( getAssociatedEntityName(), value, session );
|
||||
|
||||
if ( id == null ) {
|
||||
throw new AssertionFailure(
|
||||
"cannot cache a reference to an object with a null id: " +
|
||||
getAssociatedEntityName()
|
||||
);
|
||||
}
|
||||
|
||||
return getIdentifierType( session ).disassemble( id, session, owner );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object assemble(Serializable oid, SharedSessionContractImplementor session, Object owner) throws HibernateException {
|
||||
|
||||
//the owner of the association is not the owner of the id
|
||||
Object id = getIdentifierType( session ).assemble( oid, session, null );
|
||||
|
||||
if ( id == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return resolveIdentifier( id, session );
|
||||
//this should be a call to resolve(), not resolveIdentifier(),
|
||||
//'cos it might be a property-ref, and we did not cache the
|
||||
//referenced value
|
||||
return resolve( session.getContextEntityIdentifier(owner), session, owner );
|
||||
}
|
||||
|
||||
/**
|
||||
* We don't need to dirty check one-to-one because of how
|
||||
* assemble/disassemble is implemented and because a one-to-one
|
||||
* association is never dirty
|
||||
*/
|
||||
@Override
|
||||
public boolean isAlwaysDirtyChecked() {
|
||||
return true;
|
||||
//TODO: this is kinda inconsistent with CollectionType
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|||
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.FailureExpected;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
|
@ -120,6 +121,7 @@ public class OneToOneCacheTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-14216", reason = "The changes introduces by HHH-14216 have been reverted see https://github.com/hibernate/hibernate-orm/pull/5061 discussion")
|
||||
public void OneToOneCacheByForeignKey(SessionFactoryScope scope) throws Exception {
|
||||
OneToOneTest( PersonByFK.class, DetailsByFK.class, scope );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue