Quote:
When I run Middlegen, I get two POJOs with the following properties:
class FooPK, with properties Column1FK1, Column2FK2, Column3,
and class Foo with properties Column5, Column1FK1, Column2FK2.
in the class Foo you should also have property Column4.
In anycase, it is correct and this is the preferred approach but you could also map it so that the two many-to-one PKFK properties were accessible from the Key. I would not do it and leave it the way you have it. It separates the Key and the associations which makes life easier and its more flexible if you choose to change the mapping. What you will see is the the parent has the many-to-one mappings as update=false insert=false as these relationship values are maintained through the Key. You are right in that is a sort of wrapper where the parent has the actual domain object while the key has the primary key segment.
In CRUD type code you treat the Key just as you would any key (such as a Long), eg, loading the object.
FooPK key = new FooPK(Column1FK1Val, Column2FK2Val, Column3Val);
Foo parent = session.load(Foo.class, key);
parent.getColumn2FKDomainObject(); // Domain object
Saving a new Foo
Foo newone = new Foo();
Column2FKDomainObject c2do = new Column2FKDomainObject();
Column1FKDomainObject c1do = new Column1FKDomainObject();
session.save(c2do);
session.save(c1do);
newone.setId(new FooPK(c1do.getId(), c2do.getId(), new Long(1));
session.save(newone);
Hope this helps.