Fixed by putting the id in inheritance constructors first
@@ -509,9 +509,24 @@ public class ProxyFactory {
AbstractMethodAttribute<?, ?>[] subtypeMutableAttributes = new AbstractMethodAttribute<?, ?>[subtypeAttributesClosure.size()];
int subtypeMutableAttributeCount = 0;
+ // The id attribute always comes first
+ String idName = null;
int j = 0;
+ if (inheritanceBase instanceof ViewType<?>) {
+ idName = ((ViewType<?>) inheritanceBase).getIdAttribute().getName();
+ CtField field = fieldMap.get(idName);
+ fields[j] = field;
+ parameterTypes[j] = field.getType();
+ j++;
+ }
+
for (Map.Entry<ManagedViewTypeImpl.AttributeKey, ConstrainedAttribute<AbstractMethodAttribute<?, ?>>> entry : subtypeAttributesClosure.entrySet()) {
- CtField field = fieldMap.get(entry.getKey().getAttributeName());
+ String attributeName = entry.getKey().getAttributeName();
+ // Skip the id attribute that we handled before
+ if (attributeName.equals(idName)) {
+ continue;
+ }
+ CtField field = fieldMap.get(attributeName);
CtClass type;
if (field != null) {
type = field.getType();
