Found another thing I'm trying to understand. In the mapClass1x() method of CmpJpaConversion, there's the following code:

               pkClass = classLoader.loadClass(bean.getPrimKeyClass());
               MappedSuperclass superclass = null;
for (java.lang.reflect.Field pkField : pkClass.getFields()) {
                   String fieldName = pkField.getName();
                   int modifiers = pkField.getModifiers();
// the primary key fields must be public, non-static, must be defined as a CMP field, // AND must also exist in the class hierarchy (not enforced by mapFields()); if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers) && allFields.contains(fieldName)) {
                       superclass = superclassByField.get(fieldName);
                       if (superclass == null) {
throw new IllegalStateException("Primary key field " + fieldName + " is not defined in class " + ejbClassName + " or any super classes");
                       }
                       superclass.addField(new Id(fieldName));
                       mapping.addField(new AttributeOverride(fieldName));
                       primaryKeyFields.add(fieldName);
                   }
               }
               if (superclass != null) {
superclass.setIdClass(new IdClass(bean.getPrimKeyClass()));
               }

I have a question about the last couple of lines. If I'm reading what this (and previously executed) is doing correctly, it's setting the IdClass() attribute on the class that happens to define the last of the primary key fields. However, if I'm reading things properly, the primary key fields might not all be implemented at the same level of the class hierarchy. Is there potentially a problem here if that's the case? Would defining this attribute too early in the class hierarchy be a problem? That is, it's possible that it might be defined at a level where not all of the required fields exist yet.
Rick

Reply via email to