Reputation: 4609
I am trying to use inheritance within my business objects (jpa entitites). My question is, when I persist an object that is an instance of the subclass, which gets persisted first, the subclass entity, or the superclass entity?
For example, if I have an employee class(super) and a manager class(sub) class, when I persist a manager entity, will an entry be added to the employee table first, or the manager table first? I'm trying to figure this out to determine if I need to set the id of the manager before I persist it, or if it will be taken from the employee that was created.
Upvotes: 0
Views: 53
Reputation: 19002
It will be the super classes the first saved. Think of foreign keys from the the sub class table to the super class table in order to understand what forces that to be this way.
Upvotes: 1