I have two tables/entities. Company, Office. Company has many officies, but only one is main office - has flag main = true.
How can I ensure that only one office for given company has flag main=true.
I know I can add additional table as I ve seen here: How to Select Only Specific Children in One to Many Relation in JPA
But maybe there is another way, some validation in JPA?