i will check it out later in home, but once the cascade is just on the Persist time, i think you have to garantee that you will remove the Employee from the DB. You are just removing it from the memory. To the entity manager the record still exists.
try to do this. put on a list the elements that you want to remove on the server side and remove it from
entity manager one by one:
Code:
EntityManagerFactory emf = HibernateUtil.getEntityManagerFactory();
EntityManager em = emf.createEntityManager();
EntityTransaction transaction = em.getTransaction();
transaction.begin();
Iterator<Employee> employeesIt = department.getEmployees().iterator();
while(employeesIt .hasNext()) {
Employee employee = employeesIt .next();
em.remove(employee );
}
transaction.commit();
em.close();
the [b]em.remove(employee );[/] instructions is removing it from the db. you will see when you try to get them employees from the hotel, that ones will be no more.
--ms
**dont forget to rate if it helped **