yeah ... think of it what happens: you save a Person it assings an identifier to it but the identifies is not assigned to the Credential entity an it has to be as You are cascading and the FK tham simply fails as there is no such credential.
You might try to do the following: it seems you are using method accessors so put the following code to Your Person class:
Code:
Person {
private void setId(int id) {
this.id = id;
// add this one to set the credential PK:
this.credential.setPersonId(id);
}
}
It should work as You do not have a generator class for the Credential.id and the default strategy is
assigned .
Good Luck !