HHH-11506 - Fix update of lazy attributes when there are attributes not loaded
HHH-11506 - Deprecate methods HHH-11506 : Added original TypeHelper#findModfied and deprecated; changed deprecated methods to call the new methods.
This commit is contained in:
parent
12a1b3c225
commit
aaebcdf454
|
@ -4210,7 +4210,6 @@ public abstract class AbstractEntityPersister
|
|||
currentState,
|
||||
previousState,
|
||||
propertyColumnUpdateable,
|
||||
hasUninitializedLazyProperties( entity ),
|
||||
session
|
||||
);
|
||||
if ( props == null ) {
|
||||
|
@ -4242,7 +4241,6 @@ public abstract class AbstractEntityPersister
|
|||
old,
|
||||
propertyColumnUpdateable,
|
||||
getPropertyUpdateability(),
|
||||
hasUninitializedLazyProperties( entity ),
|
||||
session
|
||||
);
|
||||
if ( props == null ) {
|
||||
|
|
|
@ -86,7 +86,7 @@ public abstract class AbstractNonIdentifierAttribute extends AbstractAttribute i
|
|||
|
||||
@Override
|
||||
public boolean isDirtyCheckable(boolean hasUninitializedProperties) {
|
||||
return isDirtyCheckable() && ( !hasUninitializedProperties || !isLazy() );
|
||||
return isDirtyCheckable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,10 @@ public interface NonIdentifierAttribute extends Attribute, AttributeDefinition {
|
|||
|
||||
public boolean isNullable();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link org.hibernate.tuple.NonIdentifierAttribute#isDirtyCheckable()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isDirtyCheckable(boolean hasUninitializedProperties);
|
||||
|
||||
public boolean isDirtyCheckable();
|
||||
|
|
|
@ -279,6 +279,33 @@ public class TypeHelper {
|
|||
* @param includeColumns Columns to be included in the dirty checking, per property
|
||||
* @param anyUninitializedProperties Does the entity currently hold any uninitialized property values?
|
||||
* @param session The session from which the dirty check request originated.
|
||||
*
|
||||
* @return Array containing indices of the dirty properties, or null if no properties considered dirty.
|
||||
*
|
||||
* @deprecated Use {org.hibernate.type.TypeHelper{@link #findDirty(NonIdentifierAttribute[], Object[], Object[], boolean[][], SharedSessionContractImplementor)} indtead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int[] findDirty(
|
||||
final NonIdentifierAttribute[] properties,
|
||||
final Object[] currentState,
|
||||
final Object[] previousState,
|
||||
final boolean[][] includeColumns,
|
||||
final boolean anyUninitializedProperties,
|
||||
final SharedSessionContractImplementor session) {
|
||||
return findDirty( properties, currentState, previousState, includeColumns, session );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if any of the given field values are dirty, returning an array containing
|
||||
* indices of the dirty fields.
|
||||
* <p/>
|
||||
* If it is determined that no fields are dirty, null is returned.
|
||||
*
|
||||
* @param properties The property definitions
|
||||
* @param currentState The current state of the entity
|
||||
* @param previousState The baseline state of the entity
|
||||
* @param includeColumns Columns to be included in the dirty checking, per property
|
||||
* @param session The session from which the dirty check request originated.
|
||||
*
|
||||
* @return Array containing indices of the dirty properties, or null if no properties considered dirty.
|
||||
*/
|
||||
|
@ -287,7 +314,6 @@ public class TypeHelper {
|
|||
final Object[] currentState,
|
||||
final Object[] previousState,
|
||||
final boolean[][] includeColumns,
|
||||
final boolean anyUninitializedProperties,
|
||||
final SharedSessionContractImplementor session) {
|
||||
int[] results = null;
|
||||
int count = 0;
|
||||
|
@ -295,7 +321,7 @@ public class TypeHelper {
|
|||
|
||||
for ( int i = 0; i < span; i++ ) {
|
||||
final boolean dirty = currentState[i] != LazyPropertyInitializer.UNFETCHED_PROPERTY
|
||||
&& properties[i].isDirtyCheckable( anyUninitializedProperties )
|
||||
&& properties[i].isDirtyCheckable()
|
||||
&& properties[i].getType().isDirty( previousState[i], currentState[i], includeColumns[i], session );
|
||||
if ( dirty ) {
|
||||
if ( results == null ) {
|
||||
|
@ -330,7 +356,11 @@ public class TypeHelper {
|
|||
* @param session The session from which the dirty check request originated.
|
||||
*
|
||||
* @return Array containing indices of the modified properties, or null if no properties considered modified.
|
||||
*
|
||||
* @deprecated Use {@link #findModified(NonIdentifierAttribute[], Object[], Object[], boolean[][], boolean[], boolean, SharedSessionContractImplementor)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static int[] findModified(
|
||||
final NonIdentifierAttribute[] properties,
|
||||
final Object[] currentState,
|
||||
|
@ -339,6 +369,32 @@ public class TypeHelper {
|
|||
final boolean[] includeProperties,
|
||||
final boolean anyUninitializedProperties,
|
||||
final SharedSessionContractImplementor session) {
|
||||
return findModified( properties, currentState, previousState, includeColumns, includeProperties, session );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if any of the given field values are modified, returning an array containing
|
||||
* indices of the modified fields.
|
||||
* <p/>
|
||||
* If it is determined that no fields are dirty, null is returned.
|
||||
*
|
||||
* @param properties The property definitions
|
||||
* @param currentState The current state of the entity
|
||||
* @param previousState The baseline state of the entity
|
||||
* @param includeColumns Columns to be included in the mod checking, per property
|
||||
* @param includeProperties Array of property indices that identify which properties participate in check
|
||||
* @param anyUninitializedProperties Does the entity currently hold any uninitialized property values?
|
||||
* @param session The session from which the dirty check request originated.
|
||||
*
|
||||
* @return Array containing indices of the modified properties, or null if no properties considered modified.
|
||||
**/
|
||||
public static int[] findModified(
|
||||
final NonIdentifierAttribute[] properties,
|
||||
final Object[] currentState,
|
||||
final Object[] previousState,
|
||||
final boolean[][] includeColumns,
|
||||
final boolean[] includeProperties,
|
||||
final SharedSessionContractImplementor session) {
|
||||
int[] results = null;
|
||||
int count = 0;
|
||||
int span = properties.length;
|
||||
|
@ -346,7 +402,7 @@ public class TypeHelper {
|
|||
for ( int i = 0; i < span; i++ ) {
|
||||
final boolean modified = currentState[ i ] != LazyPropertyInitializer.UNFETCHED_PROPERTY
|
||||
&& includeProperties[ i ]
|
||||
&& properties[ i ].isDirtyCheckable( anyUninitializedProperties )
|
||||
&& properties[ i ].isDirtyCheckable()
|
||||
&& properties[ i ].getType().isModified( previousState[ i ], currentState[ i ], includeColumns[ i ], session );
|
||||
if ( modified ) {
|
||||
if ( results == null ) {
|
||||
|
|
|
@ -140,7 +140,7 @@ public class EnhancerTest extends BaseUnitTestCase {
|
|||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-11173" )
|
||||
@RequiresDialectFeature( value = DialectChecks.SupportsIdentityColumns.class)
|
||||
@RequiresDialectFeature( DialectChecks.SupportsIdentityColumns.class)
|
||||
public void testLazyCache() {
|
||||
EnhancerTestUtils.runEnhancerTestTask( LazyInCacheTestTask.class );
|
||||
}
|
||||
|
@ -181,6 +181,17 @@ public class EnhancerTest extends BaseUnitTestCase {
|
|||
EnhancerTestUtils.runEnhancerTestTask( SimpleLazyGroupUpdateTestTask.class );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-11506" )
|
||||
public void testLazyGroupsUpdateWithoutDirtyChecking() {
|
||||
EnhancerTestUtils.runEnhancerTestTask( SimpleLazyGroupUpdateTestTask.class , new EnhancerTestContext() {
|
||||
@Override
|
||||
public boolean doDirtyCheckingInline(UnloadedClass classDescriptor) {
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLazyCollectionNoTransactionHandling() {
|
||||
EnhancerTestUtils.runEnhancerTestTask( LazyCollectionNoTransactionLoadingTestTask.class );
|
||||
|
|
Loading…
Reference in New Issue