diff --git a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java index 71051c821c..5255cb040f 100644 --- a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java @@ -52,9 +52,11 @@ public class HibernateManyToManyAnnotationMainIntegrationTest { for(Employee employee : employeeList) { assertNotNull(employee.getProjects()); + assertEquals(2, employee.getProjects().size()); } for(Project project : projectList) { assertNotNull(project.getEmployees()); + assertEquals(2, project.getEmployees().size()); } } @@ -70,6 +72,11 @@ public class HibernateManyToManyAnnotationMainIntegrationTest { for (String emp : employeeData) { Employee employee = new Employee(emp.split(" ")[0], emp.split(" ")[1]); employee.setProjects(projects); + + for (Project proj : projects) { + proj.getEmployees().add(employee); + } + session.persist(employee); } }