Hello.
I have a simple code:
Code:
import DAO.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import savers.Unit;
public class Test {
public static void main(String args[]) throws Exception {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Unit unit = (Unit) session.createCriteria(Unit.class)
.add(Restrictions.eq("unitId", 608)).uniqueResult();
session.delete(unit);
session.getTransaction().commit();
}
}
It must to delete row in table
Unit where
unitId = 608, and delete all dependencies in other tables.
But it delete ALL rows in
Unit table and all dependent tables! Why?
Where I have to search solution?