openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Owens <>
Subject ForeignkeyAction.CASCADE not working as expected within a transaction?
Date Fri, 19 Feb 2016 19:52:14 GMT
(Sorry for the dup; accidentally posted in wrong forum earlier)

If a field in a child entity has a @ManyToOne link to a parent, and the
field is annotated with @ForeignKey(deleteAction=ForeignKeyAction.CASCADE),
and if I delete a parent, the delete does not seem to cascade as expected:
calling entityManager.find(Child.class, id) finds the child. 

For details and code see here:  Stackoverflow link

This may be because in my test case, em.remove(parent) and em.find(child)
are within the same transaction boundary, which means that they're both
operating on the OpenJPA cache rather than the database itself. But
shouldn't the cache also reflect the ForeignKey constraints? 

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message