Did you ever find a solution to this? We need our delete statements to be flushed before our insert statements (in other words, in the order that we execute the methods that result in the statements), and we really don't want to put Session calls inside our domain objects.
Manually call flush() in between the call to remove() and the call to persist().
Unfortunately i come up with calling flush as suggested by gavin. Thus this forces me either to call entity manager from an entity bean or move domain logic into the service. I've chosen the first.
Thanks. We really want to avoid putting any calls to the EntityManager inside our domain objects. For the time being, we've split up the deletes and adds into two different methods, and called them from the service bean. deleteThem(), flush(), addThem(). Ugly, but it works.
After thinking about it, we could enable immediate flushing for this service method only.