I have one process which creates a database entity and then launches a second process. It then waits on the second process to find and update the database entity before completing its processing, and thereby committing the database entity. The trouble seems to be that since the initial process which performed the entity creation has not committed the database entity by the time the second process tries to find the entity (which it can't find), the first process never completes because the second process can't complete, and things are goobered.
Some context: the first process creates an entity, launches a second process on an external machine, and sets the entity status to STARTED. The second process on the external machine makes a web service call and this web service finds the entity and updates the entity's status to READY. The first process has a loop which checks the status of the entity and once it has been changed from STARTED to READY then it does additional processing and completes. However the second process is never able to find the entity (I think) since it is never committed from the Hibernate session where it was created in the first process which has not completed by the time the second process attempts to find the entity.
What is a better way to do this so that this sort of thing won't happen? Is there a way to commit the transaction mid-way, immediately before the second process is launched, in order to have the entity present in the database for the second process to find?
Thanks for your suggestions, etc.