{"id":91301,"date":"2019-04-29T07:00:38","date_gmt":"2019-04-29T04:00:38","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=91301"},"modified":"2019-04-24T15:10:34","modified_gmt":"2019-04-24T12:10:34","slug":"hibernate-many-many-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html","title":{"rendered":"Hibernate Many To Many Tutorial"},"content":{"rendered":"<h3 class=\"wp-block-heading\" id=\"introduction\">Introduction:<\/h3>\n<p>In this tutorial, we\u2019ll learn to define and use a many-to-many entity association using Hibernate&nbsp;<em>@ManyToMany<\/em>&nbsp;annotation.<\/p>\n<h3 class=\"wp-block-heading\" id=\"context\">Context BuildUp:<\/h3>\n<p>To follow along with this tutorial, let\u2019s say we have two entities \u2013&nbsp;<em>Employee<\/em>&nbsp;and&nbsp;<em>Qualification:<\/em><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"421\" height=\"61\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/ManyToManyHibernate.png\" alt=\"Many To Many\" class=\"wp-image-91302\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/ManyToManyHibernate.png 421w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/ManyToManyHibernate-300x43.png 300w\" sizes=\"(max-width: 421px) 100vw, 421px\" \/><\/figure>\n<\/div>\n<p>As we know, one employee can multiple qualifications. Also, there can be&nbsp;<em>N<\/em>&nbsp;number of employees with a specific qualification. It clearly means that the&nbsp;<em>Employee<\/em>&nbsp;and&nbsp;<em>Qualification<\/em>entities share a&nbsp;<em>Many-to-Many relationship<\/em>.<\/p>\n<h3 class=\"wp-block-heading\" id=\"maven\">Maven Dependencies:<\/h3>\n<p>In our POM, let\u2019s first ensure we have the required dependencies:<\/p>\n<pre class=\"brush:xml\">&lt;dependencies&gt;\n    ...\n    &lt;dependency&gt;\n        &lt;groupId&gt;org.hibernate&lt;\/groupId&gt;\n        &lt;artifactId&gt;hibernate-core&lt;\/artifactId&gt;\n        &lt;version&gt;5.4.0.Final&lt;\/version&gt;\n    &lt;\/dependency&gt;\n    &lt;dependency&gt;\n        &lt;groupId&gt;mysql&lt;\/groupId&gt;\n        &lt;artifactId&gt;mysql-connector-java&lt;\/artifactId&gt;\n        &lt;version&gt;8.0.13&lt;\/version&gt;\n    &lt;\/dependency&gt;\n    ...\n&lt;\/dependencies&gt;\n<\/pre>\n<p>We can always find out the latest available version at the&nbsp;<a href=\"https:\/\/search.maven.org\/classic\/#search%7Cga%7C1%7Cg%3A%22org.hibernate%22%20AND%20a%3A%22hibernate-core%22\">Maven Central.<\/a>&nbsp;Also, we\u2019re using&nbsp;<em>MySQL<\/em>&nbsp;database for this tutorial.<\/p>\n<h3 class=\"wp-block-heading\" id=\"database-setup\">Database Setup:<\/h3>\n<p><strong>To represent a&nbsp;<em>ManyToMany<\/em>&nbsp;association, we\u2019ll at least need three database tables.<\/strong>&nbsp;So, let\u2019s say we have the below ERD diagram representing our database:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"481\" height=\"222\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/ManyToManyERDDiagram.png\" alt=\"Many To Many\" class=\"wp-image-91304\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/ManyToManyERDDiagram.png 481w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/ManyToManyERDDiagram-300x138.png 300w\" sizes=\"(max-width: 481px) 100vw, 481px\" \/><\/figure>\n<\/div>\n<p>Also, let\u2019s&nbsp;<em>create<\/em>&nbsp;our tables:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:sql\">CREATE TABLE employee (\n    emp_id INT(15) NOT NULL AUTO_INCREMENT,\n    first_name VARCHAR(20) DEFAULT NULL,\n    last_name  VARCHAR(20) DEFAULT NULL,\n    PRIMARY KEY (emp_id)\n);\n \nCREATE TABLE qualification (\n    qualification_id INT(15) NOT NULL AUTO_INCREMENT,\n    title VARCHAR(20) DEFAULT NULL,\n    PRIMARY KEY (qualification_id)\n);\n \nCREATE TABLE employee_qualification (\n    emp_id INT(15) NOT NULL,\n    qualification_id INT(15) NOT NULL,\n    PRIMARY KEY (emp_id, qualification_id),\n    CONSTRAINT employee_qualification_empIdFk \n      FOREIGN KEY (emp_id) REFERENCES employee(emp_id),\n    CONSTRAINT employee_qualification_qualIdFk \n     FOREIGN KEY (qualification_id) REFERENCES qualification (qualification_id)\n);\n<\/pre>\n<h3 class=\"wp-block-heading\" id=\"creating-entites\">Creating Entities:<\/h3>\n<p>Now that we have our database setup ready, let\u2019s first create the model class \u2013&nbsp;<em>Employee<\/em><em>:<\/em><\/p>\n<pre class=\"brush:java\">@Entity\n@Table(name = \"Employee\")\npublic class Employee { \n    \/\/ ...\n  \n    @ManyToMany(cascade = { CascadeType.ALL })\n    @JoinTable(\n        name = \"Employee_Qualification\", \n        joinColumns = { @JoinColumn(name = \"emp_id\") }, \n        inverseJoinColumns = { @JoinColumn(name = \"qualification_id\") }\n    )\n    Set&lt;Qualification&gt; qualifications = new HashSet&lt;&gt;();\n    \n    ...\n}\n<\/pre>\n<p><strong>A&nbsp;<em>Many-to-Many<\/em>&nbsp;association has two sides \u2013 the owning and the inverse\/referencing side<\/strong>.&nbsp;<strong>The actual physical mapping to the database is specified on the owning side of the relationship<\/strong>. Here,&nbsp;<em>Employee<\/em>&nbsp;is the owning entity and so we have used the<em>&nbsp;@JoinTable<\/em>annotation to define the actual physical database mapping.&nbsp;<strong>The<em>&nbsp;@JoinTable<\/em>&nbsp;annotation defines our&nbsp;<em>employee_qualification<\/em>&nbsp;join table<\/strong><em><strong>.<\/strong><\/em><\/p>\n<p>The&nbsp;<em>@JoinColumn<\/em>&nbsp;annotation specifies the column that\u2019ll be used to join the tables. We have also mentioned that&nbsp;<em>qualification_id<\/em>&nbsp;would be the inverse join column. It simply means it refers to the inverse side of the relationship which is our&nbsp;<em>Qualification<\/em>&nbsp;class.<\/p>\n<p>Let\u2019s now define our&nbsp;<em>Qualification<\/em>&nbsp;entity class:<\/p>\n<pre class=\"brush:java\">@Entity\n@Table(name = \"Qualification\")\npublic class Qualification {    \n    \/\/ ...  \n  \n    @ManyToMany(mappedBy = \"qualifications\")\n    private Set&lt;Employee&gt; employees = new HashSet&lt;&gt;();\n     \n    ...\n}\n<\/pre>\n<p>Since&nbsp;<strong><em>Qualification<\/em>&nbsp;class is the referencing or the inverse side of the association, we have used the&nbsp;<em>mappedBy<\/em>&nbsp;attribute to refer to its owning side (<em>Employee<\/em>).<\/strong><\/p>\n<p>Also as we can see, we have used&nbsp;<em>@ManyToMany<\/em>&nbsp;annotation in both of our entities.<\/p>\n<h3 class=\"wp-block-heading\" id=\"hibernate-many-to-many-usage\">Using Many-To-Many Association:<\/h3>\n<p>In our&nbsp;<em>main()<\/em>&nbsp;method, we can test out the above mapping:<\/p>\n<pre class=\"brush:java\">\/\/In our MainApp class\npublic static void main(String[] args) {\n    Session session = null;    \n    try {\n        SessionFactory factory = new Configuration()\n          .configure().buildSessionFactory();\n        session = factory.openSession();\n        Transaction tranx = session.beginTransaction();\n \n        Employee james = new Employee(1001, \"James\", \"Allen\");\n        Employee selena = new Employee(1002, \"Selena\", \"Gomez\");\n        \n        Set&lt;Employee&gt; employees = new HashSet&lt;&gt;();\n        employees.add(james);\n        employees.add(selena);\n        \n        Qualification masters = \n          new Qualification(8787, \"Masters Degree\");\n        masters.setEmployees(employees);     \n        \n        session.save(masters);\n        tranx.commit();\n    } catch(Exception e) {\n        e.printStackTrace();\n    }\n    finally {\n        if(session != null)\n            session.close();\n    }\n \n}\n<\/pre>\n<p>On executing the above code, our test data would have been inserted in our&nbsp;<em>employee<\/em>,&nbsp;<em>qualification<\/em>&nbsp;and&nbsp;<em>employee_qualification<\/em>&nbsp;tables.<\/p>\n<h3 class=\"wp-block-heading\" id=\"conclusion\">Conclusion:<\/h3>\n<p>In this mini-tutorial, we looked at how to establish a&nbsp;<em>ManyToMany<\/em>&nbsp;JPA association. We have used JPA annotations over the plain-old XML configurations as they are more convenient to use and are becoming increasingly\u001b popular.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Shubhra Srivastava, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">JCG program<\/a>. See the original article here: <a href=\"http:\/\/www.programmergirl.com\/hibernate-many-to-many\/\" target=\"_blank\" rel=\"noopener noreferrer\">Hibernate Many To Many Tutorial<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: In this tutorial, we\u2019ll learn to define and use a many-to-many entity association using Hibernate&nbsp;@ManyToMany&nbsp;annotation. Context BuildUp: To follow along with this tutorial, let\u2019s say we have two entities \u2013&nbsp;Employee&nbsp;and&nbsp;Qualification: As we know, one employee can multiple qualifications. Also, there can be&nbsp;N&nbsp;number of employees with a specific qualification. It clearly means that the&nbsp;Employee&nbsp;and&nbsp;Qualificationentities share &hellip;<\/p>\n","protected":false},"author":82253,"featured_media":153,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[971],"class_list":["post-91301","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-hibernate"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Hibernate Many To Many Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about Many To Many? Check our article explaining how to define and use a many-to-many entity association using Hibernate.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hibernate Many To Many Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Many To Many? Check our article explaining how to define and use a many-to-many entity association using Hibernate.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-29T04:00:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shubhra Srivastava\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shubhra Srivastava\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html\"},\"author\":{\"name\":\"Shubhra Srivastava\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/b73b076dc62e72de203df7018d398e56\"},\"headline\":\"Hibernate Many To Many Tutorial\",\"datePublished\":\"2019-04-29T04:00:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html\"},\"wordCount\":473,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"keywords\":[\"Hibernate\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html\",\"name\":\"Hibernate Many To Many Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"datePublished\":\"2019-04-29T04:00:38+00:00\",\"description\":\"Interested to learn about Many To Many? Check our article explaining how to define and use a many-to-many entity association using Hibernate.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-hibernate-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/hibernate-many-many-tutorial.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Hibernate Many To Many Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/b73b076dc62e72de203df7018d398e56\",\"name\":\"Shubhra Srivastava\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g\",\"caption\":\"Shubhra Srivastava\"},\"description\":\"Shubhra is a software professional and founder of ProgrammerGirl. She has a great experience with Java\\\/J2EE technologies and frameworks. She loves the amalgam of programming and coffee :)\",\"sameAs\":[\"http:\\\/\\\/www.programmergirl.com\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/shubhra-srivastava224\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/shubhra-srivastava\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hibernate Many To Many Tutorial - Java Code Geeks","description":"Interested to learn about Many To Many? Check our article explaining how to define and use a many-to-many entity association using Hibernate.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"Hibernate Many To Many Tutorial - Java Code Geeks","og_description":"Interested to learn about Many To Many? Check our article explaining how to define and use a many-to-many entity association using Hibernate.","og_url":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2019-04-29T04:00:38+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","type":"image\/jpeg"}],"author":"Shubhra Srivastava","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Shubhra Srivastava","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html"},"author":{"name":"Shubhra Srivastava","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/b73b076dc62e72de203df7018d398e56"},"headline":"Hibernate Many To Many Tutorial","datePublished":"2019-04-29T04:00:38+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html"},"wordCount":473,"commentCount":2,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","keywords":["Hibernate"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html","name":"Hibernate Many To Many Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","datePublished":"2019-04-29T04:00:38+00:00","description":"Interested to learn about Many To Many? Check our article explaining how to define and use a many-to-many entity association using Hibernate.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-hibernate-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/hibernate-many-many-tutorial.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Hibernate Many To Many Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/b73b076dc62e72de203df7018d398e56","name":"Shubhra Srivastava","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g","caption":"Shubhra Srivastava"},"description":"Shubhra is a software professional and founder of ProgrammerGirl. She has a great experience with Java\/J2EE technologies and frameworks. She loves the amalgam of programming and coffee :)","sameAs":["http:\/\/www.programmergirl.com","https:\/\/www.linkedin.com\/in\/shubhra-srivastava224\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/shubhra-srivastava"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/91301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/82253"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=91301"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/91301\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/153"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=91301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=91301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=91301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}