Yes, I would think that running a query is your best solution - em.flush will throw PersistenceException that will cause transaction to be rolled back (see spec 3.7 Summary of Exceptions), unless this is what you want.
regards,
-marina
[Message sent by forum member 'mvatkina' (mvatkina)]
http://forums.java.net/jive/thread.jspa?messageID=233916