当前位置: 首页>>代码示例>>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;未经允许,请勿转载。