private void defineClassReferenceNameDef(NameDef nd,
ClassRef cr,
SpeedoField sf,
MIBuilderHelper mibh,
String prefix) throws SpeedoException, PException {
Manager manager = mibh.getManager(cr);
SpeedoClass referencedClass = sf.moClass.getSpeedoClassFromContext(
cr.getMOClass().getFQName());
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;