out.print(key.getJavaTypeName() + " a" + i);
}
}
else {
EmbeddableType embeddable = (EmbeddableType) getEmbeddedIdField().getType();
ArrayList<AmberField> fields = embeddable.getFields();
for (int i = 0; i < fields.size(); i++) {
if (i != 0)
out.print(", ");
AmberField field = fields.get(i);
out.print(field.getJavaTypeName() + " a" + i);
}
}
out.println(")");
out.println("{");
out.pushDepth();
out.println();
out.println(getForeignTypeName() + " key = new " + getForeignTypeName() + "();");
if (getOwnerType().getPersistenceUnit().isJPA() && ! isEmbeddedId()) {
String args = "";
ArrayList<IdField> keys = getKeys();
for (int i = 0; i < keys.size(); i++) {
KeyPropertyField key = (KeyPropertyField) keys.get(i);
String name = key.getName();
char ch = Character.toUpperCase(name.charAt(0));
if (name.length() == 1)
name = "get" + ch;
else
name = "get" + ch + key.getName().substring(1);
Method method = BeanType.getGetter(_tKeyClass, name);
if (key.isKeyField() || (method != null)) {
out.println(key.generateSetKeyProperty("key", "a" + i) + ";");
}
else {
// Arg. constructor jpa/0u21
if (i != 0)
args += ", ";
args += " a" + i;
out.println("if (a" + i + " == null)");
out.println(" return new " + getForeignTypeName() + "();");
if (i + 1 == keys.size())
out.print("key = new " + getForeignTypeName() + "(" + args + ");");
}
}
}
else {
ArrayList fields;
if (getEmbeddedIdField() == null) {
// ejb/06x2
fields = getKeys();
}
else {
EmbeddableType embeddable
= (EmbeddableType) getEmbeddedIdField().getType();
fields = embeddable.getFields();
}
for (int i = 0; i < fields.size(); i++) {
AmberField field = (AmberField) fields.get(i);