A simple chain of 3 Entities with unidirectional ManyToOne associations and cascade = CascadeType.PERSIST to their parent entity works if every Entity has a simple id (also if they all have a sequence generator for that id).
Company ---o Department ---o Employee
If the last Entity (most dependent) in the chain (here Employee) uses an IdClass annotation in order to reuse the id of its parent entity then:
a) The column for the company_id in department can not be updatable = false or nullable = false
b) If all Entity instances are new created and only Employee is persisted, then the Order of statements is:
Update for Department
The foreign key column for the Department Id inside the Employee table must be nullable.
Unnecessary roundtrip to the database for the UPDATE statement.
Observed Behavior if company_id is not nullable:
WARN: HHH000437: Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity.
Foreign key column in Department can be annotated with nullable = false.
No additional UPDATE will take place.