one to many relationship:
One Bid is from 1 Item, One Item can have more than 1 Bids
Bid n ------> 1 Item
Code:
<class name="Bid"
table="BID">
...
<many-to-one name="item"
column="ITEM_ID"
class="Item"
not-null="true"/>
</class>
<class name="Item"
table="ITEM">
...
<bag name="bids"
inverse="true">
<key column="ITEM_ID"/>
<one-to-many class="Bid"/>
</bag>
</class>
O the page 167 of the book
Java Persistence with Hibernate you can find a table with the GenerationType's. Check it out and see what is the better for your case. If you have doubts use the auto. here is an example
Code:
<class name="Category" table="CATEGORY">
<id name="id" column="CATEGORY_ID" type="long">
<generator class="native"/>
</id>
...
</class>
That book is very good. Read the capter 1,2, 4, 6, 10.
**dont forget to rate if it was helpfull this tip