Javatpoint Logo

91-9990449935

 0120-4256464

Many to Many Mapping in hibernate by map Example (using xml file)

We can map many to many relation either using set, bag, map etc. Here, we are going to use map for many-to-many mapping. In such case, three tables will be created.

Example of Many to Many Mapping

You need to create following pages for mapping map elements.

  • Question.java
  • User.java
  • question.hbm.xml
  • user.hbm.xml
  • hibernate.cfg.xml
  • StoreTest.java
  • FetchTest.java

Question.java

User.java

question.hbm.xml

user.hbm.xml

hibernate.cfg.xml
StoreTest.java

FetchTest.java