Hi,
Set can't contain the duplicate value/object while Bag can.
Consider a scenario where u have 1:N relationship b/w POJOA and POJOB
and POJOA conatins collection (i.e Set)of POJOB.
Case : 1
Now If the values in FK_COLUMN_IN_YYYY_TABLE are unique then use <Set> element.
In the hibernate mapping for POJOA class u have following code
<set name ="XXXX" table ="YYYY">
<key column ="FK_COLUMN_IN_YYYY_TABLE"/>
....
</set>
Case : 2
If the values in FK_COLUMN_IN_YYYY_TABLE are duplicate
then following changes are required
a]In the database add a primary key column PK_COLUMN_IN_YYYY_TABLE
b]use <Bag> or <IdBag>
In the hibernate mapping for POJOA class u have following code
<idbag name ="XXXX" table ="YYYY">
<collection-id column ="PK_COLUMN_IN_YYYY_TABLE">
...
</collection-id>
<key column = "FK_COLUMN_IN_YYYY_TABLE"/>
...
</idbag>
If this answers ur query then kindly let me know buddy
Sunil Dixit