本文整理汇总了Java中org.hibernate.persister.entity.EntityPersister.getPropertyUpdateability方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPersister.getPropertyUpdateability方法的具体用法?Java EntityPersister.getPropertyUpdateability怎么用?Java EntityPersister.getPropertyUpdateability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.persister.entity.EntityPersister
的用法示例。
在下文中一共展示了EntityPersister.getPropertyUpdateability方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkNullability
import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
* Check nullability of the class persister properties
*
* @param values entity properties
* @param persister class persister
* @param isUpdate whether it is intended to be updated or saved
*
* @throws PropertyValueException Break the nullability of one property
* @throws HibernateException error while getting Component values
*/
public void checkNullability(
final Object[] values,
final EntityPersister persister,
final boolean isUpdate) throws HibernateException {
/*
* Typically when Bean Validation is on, we don't want to validate null values
* at the Hibernate Core level. Hence the checkNullability setting.
*/
if ( checkNullability ) {
/*
* Algorithm
* Check for any level one nullability breaks
* Look at non null components to
* recursively check next level of nullability breaks
* Look at Collections contraining component to
* recursively check next level of nullability breaks
*
*
* In the previous implementation, not-null stuffs where checked
* filtering by level one only updateable
* or insertable columns. So setting a sub component as update="false"
* has no effect on not-null check if the main component had good checkeability
* In this implementation, we keep this feature.
* However, I never see any documentation mentioning that, but it's for
* sure a limitation.
*/
final boolean[] nullability = persister.getPropertyNullability();
final boolean[] checkability = isUpdate ?
persister.getPropertyUpdateability() :
persister.getPropertyInsertability();
final Type[] propertyTypes = persister.getPropertyTypes();
for ( int i = 0; i < values.length; i++ ) {
if ( checkability[i] && values[i]!= LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
final Object value = values[i];
if ( !nullability[i] && value == null ) {
//check basic level one nullablilty
throw new PropertyValueException(
"not-null property references a null or transient value",
persister.getEntityName(),
persister.getPropertyNames()[i]
);
}
else if ( value != null ) {
//values is not null and is checkable, we'll look deeper
final String breakProperties = checkSubElementsNullability( propertyTypes[i], value );
if ( breakProperties != null ) {
throw new PropertyValueException(
"not-null property references a null or transient value",
persister.getEntityName(),
buildPropertyPath( persister.getPropertyNames()[i], breakProperties )
);
}
}
}
}
}
}
示例2: checkNaturalId
import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
private void checkNaturalId(
EntityPersister persister,
EntityEntry entry,
Object[] current,
Object[] loaded,
SessionImplementor session) {
if ( persister.hasNaturalIdentifier() && entry.getStatus() != Status.READ_ONLY ) {
if ( !persister.getEntityMetamodel().hasImmutableNaturalId() ) {
// SHORT-CUT: if the natural id is mutable (!immutable), no need to do the below checks
// EARLY EXIT!!!
return;
}
final int[] naturalIdentifierPropertiesIndexes = persister.getNaturalIdentifierProperties();
final Type[] propertyTypes = persister.getPropertyTypes();
final boolean[] propertyUpdateability = persister.getPropertyUpdateability();
final Object[] snapshot = loaded == null
? session.getPersistenceContext().getNaturalIdSnapshot( entry.getId(), persister )
: session.getPersistenceContext().getNaturalIdHelper().extractNaturalIdValues( loaded, persister );
for ( int i = 0; i < naturalIdentifierPropertiesIndexes.length; i++ ) {
final int naturalIdentifierPropertyIndex = naturalIdentifierPropertiesIndexes[i];
if ( propertyUpdateability[naturalIdentifierPropertyIndex] ) {
// if the given natural id property is updatable (mutable), there is nothing to check
continue;
}
final Type propertyType = propertyTypes[naturalIdentifierPropertyIndex];
if ( !propertyType.isEqual( current[naturalIdentifierPropertyIndex], snapshot[i] ) ) {
throw new HibernateException(
String.format(
"An immutable natural identifier of entity %s was altered from %s to %s",
persister.getEntityName(),
propertyTypes[naturalIdentifierPropertyIndex].toLoggableString(
snapshot[i],
session.getFactory()
),
propertyTypes[naturalIdentifierPropertyIndex].toLoggableString(
current[naturalIdentifierPropertyIndex],
session.getFactory()
)
)
);
}
}
}
}