Joined: Sat Oct 17, 2009 9:50 am Posts: 4
|
Hi all
I tried to use a delete statement via a query. Obviously it seems that the "Cascade" gets not recognized. It deletes only the parent object but not the child objects. Any Ideas why? Is this not supported or did I something wrong? When I do the same thing via the entityManager it works fine e.g. entityManager.remove(parent); Thanky oyu for any hints.
Example JPA mapping:
class Parent { @OneToMany (cascade=CascadeType.ALL) @JoinColumn(name = "parent_id", nullable = false) private List<Child> childs= new ArrayList<Child>(); }
In my DAO:
StringBuffer sb = new StringBuffer("delete from Parent p"); Query query = entityManager.createQuery (sb.toString()); query.executeUpdate();
During execution it shows only one SQL statement:
Hibernate: delete from parent
|
|