Google App Engine - DELETE JPQL Query and Cascading
Posted
by Taylor Leese
on Stack Overflow
See other posts from Stack Overflow
or by Taylor Leese
Published on 2010-06-08T08:17:27Z
Indexed on
2010/06/08
8:22 UTC
Read the original article
Hit count: 271
I noticed that the children of PersistentUser are not deleted when using the JPQL query below. However, the children are deleted if I perform an entityManager.remove(object)
. Is this expected? Why doesn't the JPQL query below also perform a cascaded delete?
@OneToMany(mappedBy = "persistentUser", cascade = CascadeType.ALL)
private Collection<PersistentLogin> persistentLogins;
...
@Override
@Transactional
public final void removeUserTokens(final String username) {
final Query query = entityManager.createQuery(
"DELETE FROM PersistentUser p WHERE username = :username");
query.setParameter("username", username);
query.executeUpdate();
}
© Stack Overflow or respective owner