First of all, are you sure you want to end up with a bunch of orphaned records (employees pointing to non-existent departments)? Forcing your application to ignore referential integrity will almost always come back to haunt you. Moreover, it's not hibernate, but the database that is complaining. You define foreign key constraints in your schema precisely for the purpose of preventing orphaned records. Therefore, the easiest way to get what you are asking is to remove your foreign key constraints.
|