HHH-6467 - Non-association attributes are not dirty-checked
This commit is contained in:
parent
c7ae4477ae
commit
dd2cbf863d
|
@ -40,6 +40,7 @@ import org.hibernate.metamodel.binding.AttributeBinding;
|
||||||
import org.hibernate.metamodel.binding.EntityBinding;
|
import org.hibernate.metamodel.binding.EntityBinding;
|
||||||
import org.hibernate.metamodel.binding.AbstractPluralAttributeBinding;
|
import org.hibernate.metamodel.binding.AbstractPluralAttributeBinding;
|
||||||
import org.hibernate.metamodel.binding.SimpleSingularAttributeBinding;
|
import org.hibernate.metamodel.binding.SimpleSingularAttributeBinding;
|
||||||
|
import org.hibernate.metamodel.binding.SimpleValueBinding;
|
||||||
import org.hibernate.metamodel.binding.SingularAttributeBinding;
|
import org.hibernate.metamodel.binding.SingularAttributeBinding;
|
||||||
import org.hibernate.property.Getter;
|
import org.hibernate.property.Getter;
|
||||||
import org.hibernate.property.PropertyAccessor;
|
import org.hibernate.property.PropertyAccessor;
|
||||||
|
@ -111,6 +112,9 @@ public class PropertyFactory {
|
||||||
final SimpleSingularAttributeBinding property = mappedEntity.getEntityIdentifier().getValueBinding();
|
final SimpleSingularAttributeBinding property = mappedEntity.getEntityIdentifier().getValueBinding();
|
||||||
|
|
||||||
// TODO: the following will cause an NPE with "virtual" IDs; how should they be set?
|
// TODO: the following will cause an NPE with "virtual" IDs; how should they be set?
|
||||||
|
// (steve) virtual attributes will still be attributes, they will simply be marked as virtual.
|
||||||
|
// see org.hibernate.metamodel.domain.AbstractAttributeContainer.locateOrCreateVirtualAttribute()
|
||||||
|
|
||||||
final String mappedUnsavedValue = property.getUnsavedValue();
|
final String mappedUnsavedValue = property.getUnsavedValue();
|
||||||
final Type type = property.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
final Type type = property.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
|
|
||||||
|
@ -194,7 +198,7 @@ public class PropertyFactory {
|
||||||
VersionValue unsavedValue = UnsavedValueFactory.getUnsavedVersionValue(
|
VersionValue unsavedValue = UnsavedValueFactory.getUnsavedVersionValue(
|
||||||
mappedUnsavedValue,
|
mappedUnsavedValue,
|
||||||
getGetter( property ),
|
getGetter( property ),
|
||||||
( VersionType ) property.getHibernateTypeDescriptor().getResolvedTypeMapping(),
|
(VersionType) property.getHibernateTypeDescriptor().getResolvedTypeMapping(),
|
||||||
getConstructor( property.getEntityBinding() )
|
getConstructor( property.getEntityBinding() )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -302,7 +306,7 @@ public class PropertyFactory {
|
||||||
|| singularAttributeBinding.getGeneration() == PropertyGeneration.ALWAYS,
|
|| singularAttributeBinding.getGeneration() == PropertyGeneration.ALWAYS,
|
||||||
singularAttributeBinding.getGeneration() == PropertyGeneration.ALWAYS,
|
singularAttributeBinding.getGeneration() == PropertyGeneration.ALWAYS,
|
||||||
singularAttributeBinding.isNullable(),
|
singularAttributeBinding.isNullable(),
|
||||||
alwaysDirtyCheck,
|
alwaysDirtyCheck || areAllValuesIncludedInUpdate( singularAttributeBinding ),
|
||||||
singularAttributeBinding.isIncludedInOptimisticLocking(),
|
singularAttributeBinding.isIncludedInOptimisticLocking(),
|
||||||
cascadeStyle,
|
cascadeStyle,
|
||||||
fetchMode
|
fetchMode
|
||||||
|
@ -311,10 +315,10 @@ public class PropertyFactory {
|
||||||
else {
|
else {
|
||||||
final AbstractPluralAttributeBinding pluralAttributeBinding = (AbstractPluralAttributeBinding) property;
|
final AbstractPluralAttributeBinding pluralAttributeBinding = (AbstractPluralAttributeBinding) property;
|
||||||
final CascadeStyle cascadeStyle = pluralAttributeBinding.isAssociation()
|
final CascadeStyle cascadeStyle = pluralAttributeBinding.isAssociation()
|
||||||
? ( (AssociationAttributeBinding) pluralAttributeBinding ).getCascadeStyle()
|
? pluralAttributeBinding.getCascadeStyle()
|
||||||
: CascadeStyle.NONE;
|
: CascadeStyle.NONE;
|
||||||
final FetchMode fetchMode = pluralAttributeBinding.isAssociation()
|
final FetchMode fetchMode = pluralAttributeBinding.isAssociation()
|
||||||
? ( (AssociationAttributeBinding) pluralAttributeBinding ).getFetchMode()
|
? pluralAttributeBinding.getFetchMode()
|
||||||
: FetchMode.DEFAULT;
|
: FetchMode.DEFAULT;
|
||||||
|
|
||||||
return new StandardProperty(
|
return new StandardProperty(
|
||||||
|
@ -323,13 +327,10 @@ public class PropertyFactory {
|
||||||
type,
|
type,
|
||||||
lazyAvailable && pluralAttributeBinding.isLazy(),
|
lazyAvailable && pluralAttributeBinding.isLazy(),
|
||||||
// TODO: fix this when HHH-6356 is fixed; for now assume AbstractPluralAttributeBinding is updatable and insertable
|
// TODO: fix this when HHH-6356 is fixed; for now assume AbstractPluralAttributeBinding is updatable and insertable
|
||||||
// pluralAttributeBinding.isInsertable(),
|
true, // pluralAttributeBinding.isInsertable(),
|
||||||
//pluralAttributeBinding.isUpdatable(),
|
true, //pluralAttributeBinding.isUpdatable(),
|
||||||
true,
|
|
||||||
true,
|
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
// pluralAttributeBinding.isNullable(),
|
|
||||||
false, // nullable - not sure what that means for a collection
|
false, // nullable - not sure what that means for a collection
|
||||||
// TODO: fix this when HHH-6356 is fixed; for now assume AbstractPluralAttributeBinding is updatable and insertable
|
// TODO: fix this when HHH-6356 is fixed; for now assume AbstractPluralAttributeBinding is updatable and insertable
|
||||||
//alwaysDirtyCheck || pluralAttributeBinding.isUpdatable(),
|
//alwaysDirtyCheck || pluralAttributeBinding.isUpdatable(),
|
||||||
|
@ -341,6 +342,18 @@ public class PropertyFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean areAllValuesIncludedInUpdate(SingularAttributeBinding attributeBinding) {
|
||||||
|
if ( attributeBinding.hasDerivedValue() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for ( SimpleValueBinding valueBinding : attributeBinding.getSimpleValueBindings() ) {
|
||||||
|
if ( ! valueBinding.isIncludeInUpdate() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static Constructor getConstructor(PersistentClass persistentClass) {
|
private static Constructor getConstructor(PersistentClass persistentClass) {
|
||||||
if ( persistentClass == null || !persistentClass.hasPojoRepresentation() ) {
|
if ( persistentClass == null || !persistentClass.hasPojoRepresentation() ) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -50,7 +50,6 @@ public class SimpleOpsTest extends AbstractOperationTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpected( jiraKey = "HHH-6467" )
|
|
||||||
public void testBasicOperations() {
|
public void testBasicOperations() {
|
||||||
clearCounts();
|
clearCounts();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue