Hibernate Mapping Cheat Sheet. A many-to-many reference is basically a collection.
Class A holds a reference to a set of class B instances (as in the one-to-many case), but B might have multiple A's. Scenario We have two classes, Foo and Bar which are related to each other as follows: Set Foo.getBars() // of Bar instances<class name="Foo" table="foo"> ... <set role="bars" table="foo_bar"><key column="foo_id"/><many-to-many column="bar_id" class="Bar"/></set> </class> Generic DAO example - BeJUG - The Belgian Java User Group. One very useful application of generics is in the Data Access Object pattern, especially when using JPA or Hibernate.
Using generics, this pattern can almost evolve into the 'One DAO to Rule Them All' pattern Let's start with the interface for such generic DAO. You can download the source code at the bottom of this page.