openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Owens <c...@chris-owens.com>
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
<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.

Mime
View raw message