There's no need to iterate if you just keep the reference to the object you added. Consider this pseudo-code:
Now, in this example, if the mapping document for Car specifies a collection of tires and that association has cascade="all" (for example), the last statement there does the following: 1) update the Car object's data to database 2) assign an id for the Tire object we just created and save it to database 3) update the association table to associate 'tire' with 'car'
In other words, after the above code snippet is executed, the Tire object is stored in the database and the object has an id -- which you can query with a simple getter.
If you happen to be using the Transaction API, you don't need to worry about this step. It will be performed implicitly when the transaction is committed. Otherwise you should call Session.flush() to ensure that all changes are synchronized with the database.
but which is better, or, is there any relevant criteria for using one in preference for another? i'm using MySql standard in a stand alone app [ March 09, 2005: Message edited by: miguel lisboa ]
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with: