I'm using Hibernate with "Table per subclass" method. But unfortunately with slightly different table definition than the "best practices" which are described for the subclass-method. This is because the database administrator won't accept the hibernate design with the foreign keys in the subclass-tables but instead he want's foreign keys from the baseclass-table to the subclass-tables
The schema looks like this:
TABLE BASE
ID <PK>
Class-A <FK TABLE A>
Class-B <FK TABLE B>
TABLE A
ID <PK>
TABLE B
ID <PK>
I dont have the opportunity to change the schema without huge discussions about it.
Now to the problem:
If we let hibernate save a derived class, the order of insertion is
hibernate: insert BASE (...)
hibernate: insert A (...)
but with this order, the constraint PK<>FK is violated! What i want hibernate to do is to first insert the subclass A and THEN the "data bag" base class. Does anybody know if and where this can be configured?