Is it possible to have a CTI in Doctrine 2 that does not shared the autoincrement? For example, i have a Pet entity and two sub-classes, Cat and Dog. However, if i create two dogs and one cat, the next ID for BOTH entities will be 4. I wanted Dog and Cat to have it’s own autoincrement.
Is it possible to have a CTI in Doctrine 2 that does not shared
Share
I don’t see how would this work, regardless of doctrine.
What if you don’t know which entity to expect and have only the id?
For example get the Pet with id 4?
You can’t query by base class, which IMHO breaks the purpose of inheritance.
With CTI you get separate tables, but still it is just plain inheritance, CTI is just a object-relational mapping shema.
From the object model perspective having two entities of same type with the same id just doesn’t make sense.
So you can either stick with what you have, or get rid of the inheritance completely and manage Cat and Dog as two independent entities. I would suggest you stick with the first option.
Also, with CTI there is no autoincrement on Cat and Dog, only on Pet. Child tables just copy the ID from parent, regardless how the ID was generated.