That makes perfectly sense - it works exactly as it should work. Table advertisement_day_to_time_slots
is a join table between Advertisement
and DayToTimeSlot
entities. Relation between these entities is built with join table because association is unidirectional one-to-many.
This join table do have unique constraint in day_to_time_slot column, because each DayToTimeSlot can be connected only to the one Advertisement entitity. Inverse of OneToMany is ManyToOne. One Advertisement can be connected to many DayToTimeSlot entities, but one DayToTimeSlot is associated only with one Advertisement. If such a limitation is not preferred, @ManyToMany association should be used instead of OneToMany.