本文整理匯總了Java中org.hibernate.metadata.ClassMetadata.setPropertyValue方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassMetadata.setPropertyValue方法的具體用法?Java ClassMetadata.setPropertyValue怎麽用?Java ClassMetadata.setPropertyValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.metadata.ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata.setPropertyValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updaterCopyToPersistentObject
import org.hibernate.metadata.ClassMetadata; //導入方法依賴的package包/類
/**
* 將更新對象拷貝至實體對象,並處理many-to-one的更新。
*
* @param updater
* @param po
*/
private void updaterCopyToPersistentObject(Updater<T> updater, T po,
ClassMetadata cm) {
String[] propNames = cm.getPropertyNames();
String identifierName = cm.getIdentifierPropertyName();
T bean = updater.getBean();
Object value;
for (String propName : propNames) {
if (propName.equals(identifierName)) {
continue;
}
try {
value = MyBeanUtils.getSimpleProperty(bean, propName);
if (!updater.isUpdate(propName, value)) {
continue;
}
cm.setPropertyValue(po, propName, value, POJO);
} catch (Exception e) {
throw new RuntimeException(
"copy property to persistent object failed: '"
+ propName + "'", e);
}
}
}
示例2: fixupRelationship
import org.hibernate.metadata.ClassMetadata; //導入方法依賴的package包/類
/**
* Set an association value based on the value of the foreign key. This updates the property of the entity.
* @param propName Name of the navigation/association property of the entity, e.g. "Customer". May be null if the property is the entity's identifier.
* @param propType Type of the property
* @param entityInfo Breeze EntityInfo
* @param meta Metadata for the entity class
*/
private void fixupRelationship(String propName, EntityType propType, EntityInfo entityInfo, ClassMetadata meta)
{
Object entity = entityInfo.entity;
if (removeMode) {
meta.setPropertyValue(entity, propName, null);
return;
}
Object relatedEntity = getPropertyValue(meta, entity, propName);
if (relatedEntity != null) {
// entities are already connected - still need to add to dependency graph
EntityInfo relatedEntityInfo = saveWorkState.findEntityInfo(relatedEntity);
maybeAddToGraph(entityInfo, relatedEntityInfo, propType);
return;
}
relatedEntity = getRelatedEntity(propName, propType, entityInfo, meta);
if (relatedEntity != null) {
meta.setPropertyValue(entity, propName, relatedEntity);
}
}
示例3: restoreOldVersionValue
import org.hibernate.metadata.ClassMetadata; //導入方法依賴的package包/類
/**
* Restore the old value of the concurrency column so Hibernate will save the entity.
* Otherwise it will complain because Breeze has already changed the value.
* @param entityInfo
* @param classMeta
*/
protected void restoreOldVersionValue(EntityInfo entityInfo, ClassMetadata classMeta) {
if (entityInfo.originalValuesMap == null || entityInfo.originalValuesMap.size() == 0)
return;
int vcol = classMeta.getVersionProperty();
String vname = classMeta.getPropertyNames()[vcol];
if (entityInfo.originalValuesMap.containsKey(vname)) {
Object oldVersion = entityInfo.originalValuesMap.get(vname);
Object entity = entityInfo.entity;
if (oldVersion == null) {
_possibleErrors.add("Hibernate does not support 'null' version properties. " +
"Entity: " + entity + ", Property: " + vname);
}
Class versionClazz = classMeta.getPropertyTypes()[vcol].getReturnedClass();
DataType dataType = DataType.fromClass(versionClazz);
Object oldValue = DataType.coerceData(oldVersion, dataType);
classMeta.setPropertyValue(entity, vname, oldValue);
}
}