openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aroche <aro...@gmail.com>
Subject Deleting based on CriteriaQuery
Date Thu, 07 Feb 2013 10:26:51 GMT
We are using a 3rd party tool for displaying table lists on screen
(specifically Vaadin CriteriaContainer though it probably doesn't matter
here). It uses CriteriaQueries for filtering data in the table.

One of the use cases is to delete all items that match the filter (which is
basically a CriteriaQuery).

I'm looking for the cleanest way in OpenJPA to convert a CriteriaQuery
(SELECT) to a DELETE. 
JPA 2.1 introduces this functionality but obviously that is some way off in
the future.

So one solution I'm thinking about is to get the QueryImpl from the typed
query.
ie. org.apache.openjpa.persistence.QueryImpl query =
typedQuery.unwrap(org.apache.openjpa.persistence.QueryImpl.class);

Then to get the Select query and do wrap in a delete and bind the parameters
etc to perform the delete.

Would this work?
Is there a neater way to do this? ie. using QueryImpl, or TypedQuery etc.?

Thanks for any advice!



--
View this message in context: http://openjpa.208410.n2.nabble.com/Deleting-based-on-CriteriaQuery-tp7582729.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message