We use Hibernate API to manage persistence of our data into a Postgresql database.
we built a complex J2EE system that uses many components communicating together in different ways such as Spring managed beans , EJB and JMS for asynchronous messaging.
we are testing our system now. to be able to wait until a JMS message has been received ,consumed and replied.. and also for all Transaction logic within the JMS MDBean to complete, we used a quick & dirty technique which is using Thread.sleep() statements to pause the system for few secs until one transaction has completed ,so the system pass to next transaction without the causing errors or conflicts between concurring Hibernate transactions.
we are aware this is Not a clean technique and want to Find a better solution for this problem:
How to tell hibernate to LOCK a given transaction and pause all other transactions until current one is complete? is there some Java code to do this ? do we need to configure some jboss xml files to tell hibernate how to synchronize its transactions?
I'm not yet mastering the hibernate API very well and would appreciate if you suggest some good solutions to the problem i described above.