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


Java ReferenceAttributeNotAnOjbReferenceException類代碼示例

本文整理匯總了Java中org.kuali.rice.krad.exception.ReferenceAttributeNotAnOjbReferenceException的典型用法代碼示例。如果您正苦於以下問題:Java ReferenceAttributeNotAnOjbReferenceException類的具體用法?Java ReferenceAttributeNotAnOjbReferenceException怎麽用?Java ReferenceAttributeNotAnOjbReferenceException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ReferenceAttributeNotAnOjbReferenceException類屬於org.kuali.rice.krad.exception包,在下文中一共展示了ReferenceAttributeNotAnOjbReferenceException類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: determineFkMap

import org.kuali.rice.krad.exception.ReferenceAttributeNotAnOjbReferenceException; //導入依賴的package包/類
private Map determineFkMap(Class clazz, String attributeName, Class attributeClass) {
	Map fkMap = new HashMap();
	EntityDescriptor entityDescriptor = MetadataManager.getEntityDescriptor(clazz);
	ObjectDescriptor objectDescriptor = entityDescriptor.getObjectDescriptorByName(attributeName);
	if (objectDescriptor == null) {
		throw new ReferenceAttributeNotAnOjbReferenceException("Attribute requested (" + attributeName + ") is not defined in JPA annotations for class: '" + clazz.getName() + "'");
	}

	// special case when the attributeClass passed in doesnt match the
	// class of the reference-descriptor as defined in ojb-repository.
	// Currently
	// the only case of this happening is ObjectCode vs.
	// ObjectCodeCurrent.
	if (!attributeClass.equals(objectDescriptor.getTargetEntity())) {
		if (referenceConversionMap.containsKey(attributeClass)) {
			attributeClass = referenceConversionMap.get(attributeClass);
		} else {
			throw new RuntimeException("The Class of the Java member [" + attributeClass.getName() + "] '" + attributeName + "' does not match the class of the reference [" + objectDescriptor.getTargetEntity().getName() + "]. " + "This is an unhandled special case for which special code needs to be written in this class.");
		}
	}

	// get the list of the foreign-keys for this reference-descriptor
	// (OJB)
	List<String> fkFields = objectDescriptor.getForeignKeyFields();
	Iterator<String> fkIterator = fkFields.iterator();

	// get the list of the corresponding pk fields on the other side of
	// the relationship
	List pkFields = getPrimaryKeys(attributeClass);
	Iterator pkIterator = pkFields.iterator();

	// make sure the size of the pkIterator is the same as the
	// size of the fkIterator, otherwise this whole thing is borked
	if (pkFields.size() != fkFields.size()) {
		throw new RuntimeException("KualiPersistenceStructureService Error: The number of " + "foreign keys doesnt match the number of primary keys.");
	}

	// walk through the list of the foreign keys, get their types
	while (fkIterator.hasNext()) {
		// if there is a next FK but not a next PK, then we've got a big
		// problem,
		// and cannot continue
		if (!pkIterator.hasNext()) {
			throw new RuntimeException("The number of foriegn keys dont match the number of primary keys for the reference '" + attributeName + "', on BO of type '" + clazz.getName() + "'.  " + "This should never happen under normal circumstances.");
		}

		// get the field name of the fk & pk field
		String fkFieldName = (String) fkIterator.next();
		String pkFieldName = (String) pkIterator.next();

		// add the fieldName and fieldType to the map
		fkMap.put(fkFieldName, pkFieldName);
	}
	return fkMap;
}
 
開發者ID:aapotts,項目名稱:kuali_rice,代碼行數:56,代碼來源:PersistenceStructureServiceJpaImpl.java


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