當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassMetadata.setPropertyValue方法代碼示例

本文整理匯總了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);
		}
	}
}
 
開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:30,代碼來源:HibernateBaseDao.java

示例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);
    }
}
 
開發者ID:Breeze,項目名稱:breeze.server.java,代碼行數:29,代碼來源:RelationshipFixer.java

示例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);
    }
}
 
開發者ID:Breeze,項目名稱:breeze.server.java,代碼行數:25,代碼來源:HibernateSaveProcessor.java


注:本文中的org.hibernate.metadata.ClassMetadata.setPropertyValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。