SpeedoClass clazzWithIdField = referencedClass.getAncestor();
if (clazzWithIdField == null) {
clazzWithIdField = referencedClass;
}
CompositeName cn = manager.getCompositeName(clazzWithIdField.identity.objectidClass);
NameRef nr = nd.createNameRef(cn);
List idFields = clazzWithIdField.getPKFields();
for (int i = 0; i < idFields.size(); i++) {
SpeedoField pkField = (SpeedoField) idFields.get(i);
int size = PType.NOSIZE;
int scale = PType.NOSIZE;
if (pkField.columns != null && pkField.columns.length == 1) {
if (pkField.columns[0].length != -1) {
size = pkField.columns[0].length;
}
if (pkField.columns[0].scale != -1) {
scale = pkField.columns[0].scale;
}
}
// create a hidden field in the class corresponding to this
// composite Name field. The name is based on a prefix (ClassRef name)
String fieldName = prefix + pkField.name;
PType type = mibh.getPrimitivePType(Type.getType(pkField.type));
if (logger.isLoggable(BasicLevel.DEBUG)) {
logger.log(BasicLevel.DEBUG, "\tField: name=" + fieldName
+ ", type=" + type.getJavaName());
}
mibh.createNameDefField(cr.getParent(), fieldName, type, size, scale);
//define the projection between composite name fields and field used
// in NameRef
nr.addProjection(pkField.name, fieldName);
}
}