You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Chris Owens <ct...@chris-owens.com> on 2016/02/19 20:52:14 UTC

ForeignkeyAction.CASCADE not working as expected within a transaction?

(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
<http://stackoverflow.com/questions/35494608/foreign-key-cascade-delete-not-working-as-expected-in-openjpa-postgresql>  

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: http://openjpa.208410.n2.nabble.com/ForeignkeyAction-CASCADE-not-working-as-expected-within-a-transaction-tp7588945.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.