I'm developing a custom user bundle for a symfony2 application which has 3 types of users: Administrator, Professor and Student. Each type of user has an identifier (the national identity number, in Spanish: dni) and another data like name, lastName, etc. (data between different user's type are disjoint)
My problem is that I need that a dni is never repeated, regardless of the user's type.
I have used the UniqueEntity annotation and this works, but only with entities of the same type.
How I could do it for entities of different type?
I have thought to use the callback annotation and check with a query that in the other entities there is no entity with that dni but for that I have to use the entity manager inside of an entity and this is a bad practise.
Do exist another way to do this?
Greetings and thanks.