Unique constraints created for ManyToOne mapping

Hi All,
With the upgrade to Spring Boot 3.1 (from 2.7.2) with hibernate version 6.2.6, hibernate creates unique constraint for the columns annotated with ManyToOne which was not the case with hibernate 5.7. We use import sql for our test data in H2 and the setup (insertion) of the test data fails with org.hibernate.exception.ConstraintViolationException - org.springframework.dao.DataIntegrityViolationException: could not execute statement [Unique index or primary key violation: “X.CONSTRAINT_INDEX_F ON X.”“ns::ns.table”“(fk_col) VALUES 1”
For a OneToOne mapping, unique constraint creation is fine. However, for a ManyToOne mapping, for e.g, Student to School: many students studying in the same school. Here, say Student entity has a ManyToOne mapping to school id (Primary Key) of School entity. In this case, Student table can have repeated values for school id (representing different students studying in the same school) and this is restricted by the unique constraint created by default.
I have disabled unique constraint creation by using this in JoinColumn annotation. -

foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)

Is the creation of unique constraint by default the expected behavior for ManyToOne mapping? Or am I understanding it incorrectly?

This is neither expected nor the actual behavior of ORM. Unique constraints are only created for one-to-one associations and one-to-many join table associations. Please provide reproducer that shows this behavior using our test case template: https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java

Hi; is this an issue; i have the same problem; and the issue is easy to reproduce; for example, lets say an User entity and Role entity; an user could have many roles, for that reason you could use @OneToMany annotation in User, related on Role; but if you add @JoinTable annotation in User and @OneToMany, annotation, the JoinTable created has a unique index in idrole, created by hibernate, why?

If it’s so easy to reproduce, then please create a reproducer application based on our test case template and attach that to a new Jira issue.