Hibernate Many to Many Example using AnnotationIn the previous section, we have performed many to many mapping using XML file. Here, we are going to perform this task using annotation. We can map many to many relation either using list, set, bag, map etc. Here, we are going to use list for many-to-many mapping. In such case, three tables will be created. Example of Many to Many MappingIn this example, we will generate a many to many relation between questions and answers by list. 1) Create the Persistent classQuestion.java Answer.java 2) Add project information and configuration in pom.xml file.Open pom.xml file and click source. Now, add the below dependencies between <dependencies>....</dependencies> tag. 3) Create the configuration fileThis file contains information about the database and mapping file. 4) Create the class to store the dataStoreData.java OutputDownload
Next TopicOne to One XML
|