Relative Content

Tag Archive for javaspringspring-boothibernatespring-data-jpa

OneToMany on Map in Hibernate (spring boot) creates unique constraint?

I am creating the backend for a boardgame in Spring Boot. This boardgame can have 1 to n players that each get a color. Player is an entity, just as Game. Color is an enum. It seemed to me a good idea to store the players of a game in a Map<Color, Player>. This allows me to dynamically store the players with the color as key and gives me cleaner code.
However, if I use the following code: