Profesor profesor=new Profesor(7, "Sara", "Barrrera", "Salas"); Set correosElectronicos=new HashSet<>(); correosElectronicos.add(new CorreoElectronico(3, "sara@yahoo.com",profesor)); correosElectronicos.add(new CorreoElectronico(2, "sara@hotmail.com",profesor)); correosElectronicos.add(new CorreoElectronico(1, "sara@gmail.com",profesor)); profesor.setCorreosElectronicos(correosElectronicos); Session session=sessionFactory.openSession(); session.beginTransaction(); session.save(profesor); session.getTransaction().commit(); session.close();