Добрый день!
В БД реализована связь многие ко - многим между params,params_and values,launches:
Мне необходимо вставить сущности в launches, params_and_values, для каждого значения из params. hibernate-код вставки данных:
currSes= HibernateUtil.getSessionFactory().getCurrentSession();
currSes.beginTransaction();
Collection<ParamsEntity> pe = currSes.createCriteria(ParamsEntity.class).list();
Hibernate.initialize(pe);
currSes.getTransaction().commit();
for (ParamsEntity paramsEntity : pe) {
currSes= HibernateUtil.getSessionFactory().getCurrentSession();
currSes.beginTransaction();
le= (LaunchesEntity) currSes.load(LaunchesEntity.class, launchId);
ParamsAndValuesEntity pve= new ParamsAndValuesEntity();
pve.setLaunchesByLaunchId(le);
pve.setParamsByParamsId(paramsEntity);
pve.setParamValue("meow");
currSes.save(pve);
currSes.getTransaction().commit();
}
Выскакивает исключение:
MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails
Почему это не работает?=(