本文整理汇总了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;
}