Hibernate version: 2.1
I apologize if this has been addressed elsewhere but I have tried to search for an answer and as I haven't found one I've decided to ask here...
I've been looking at the auction example that comes with the Hibernate 2.1 (and 3.0) download. The example constructs tables, populates them with data and runs various queries and transactions on them. In one of these, bidOnAuction in the Main class, there are locks placed on two objects:
s.lock(item, LockMode.NONE);
s.lock(bidder, LockMode.NONE);
In the context of the example, I couldn't quite understand the necessity of these statements since we are then creating a new bid that relates to these objects via foreign keys. But if I comment the statements out what happens is the bid is not inserted until much later in the chain of actions in our test.
So it appears the lock statements ensure that the bid is inserted before the next query is executed.
Could someone kindly clarify why these statements are in fact needed and how using them acheives this result, and why without them the bid insert is delayed?
Thanks in advance,
Dan
|