<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1110200500196347069</id><updated>2024-10-06T21:16:56.602-07:00</updated><title type='text'>JPA Modeler</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jpamodeler.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1110200500196347069/posts/default'/><link rel='alternate' type='text/html' href='http://jpamodeler.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/16315177036314487677</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1110200500196347069.post-1084100328668806806</id><published>2015-12-21T05:57:00.000-08:00</published><updated>2016-04-07T20:45:40.975-07:00</updated><title type='text'>@NamedEntityGraph in Action</title><content type='html'> &lt;script&gt;window.location.href=&quot;http://jpamodeler.github.io/tutorial/page.html?l=NamedEntityGraph&quot;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;h3 id=&quot;TOC&quot; style=&quot;text-align: left;&quot;&gt;Table of Content :&lt;/h3&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;INT&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#EG&quot;&gt;Entity Graph&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#DIA&quot;&gt;Create the JPA Diagram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#CRE&quot;&gt;Create the Entities&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#CEG&quot;&gt;Create the @NamedEntityGraph&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#NES&quot;&gt;Named sub graph&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#EGT&quot;&gt;Entity Graph types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#GSRC&quot;&gt;Generate Source Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#EGI&quot;&gt;Obtain EntityGraph Instance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#EGQ&quot;&gt;Entity Graphs in Query Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#DSRC&quot;&gt;Download Source Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#CON&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;h4 id=&quot;INT&quot;&gt;Introduction :&lt;/h4&gt;The Java Persistence API provides a powerful interface for object-relational mapping. Its usage is straightforward for simple models, but complex models require care and expertise to achieve good performance. JPA loading strategies are a key factor for better performance.  &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt; JPA 2.1 introduced a new feature :&lt;/b&gt; &lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;Entity Graphs - as a means to address the long standing problem of fetching to different depths in the Entity graph for different use cases.&amp;nbsp;&lt;/blockquote&gt;JPA 2.1 entity graphs are a better solution to specify the path and boundaries for find operations or queries. The definition of an entity graph is independent of the query and defines which attributes to fetch from the database.&lt;br /&gt;
This blog post describes how we can create named entity graph by using JPA Modeler and explains how fetch settings and entity graphs in JPA 2.1 can be used to implement various loading strategies.&lt;br /&gt;
&lt;h4 id=&quot;EG&quot;&gt;Entity Graph:&lt;/h4&gt;When an object is retrieved from the datastore by JPA typically not all fields are retrieved immediately. This is because for efficiency purposes only particular field types are retrieved in the initial access of the object, and then any other objects are retrieved when accessed (lazy loading). The group of fields that are loaded is called an &lt;b&gt;entity graph&lt;/b&gt;. There are 3 types of &quot;entity graphs&quot; to consider&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;Default Entity Graph:&lt;/b&gt; implicitly defined in all JPA specs, specifying the&amp;nbsp;&lt;i&gt;fetch&lt;/i&gt;&amp;nbsp;setting for each field/property (LAZY/EAGER).&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Named Entity Graphs:&lt;/b&gt; a new feature in JPA 2.1 allowing the user to define Named Entity Graphs in metadata, via annotations &lt;code&gt;&lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/NamedEntityGraph.html&quot; target=&quot;_blank&quot;&gt;@NamedEntityGraph&lt;/a&gt;&lt;/code&gt; or deployment descriptor.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Unnamed Entity Graphs (Dynamic):&lt;/b&gt; a new feature in JPA 2.1 allowing the user to define Entity Graphs via the &lt;code&gt;&lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/EntityManager.html#createEntityGraph-java.lang.String-&quot; target=&quot;_blank&quot;&gt;createEntityGraph()&lt;/a&gt;&lt;/code&gt; method of &lt;code&gt;&lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/EntityManager.html&quot; target=&quot;_blank&quot;&gt;EntityManager&lt;/a&gt;&lt;/code&gt; API at runtime.&lt;/li&gt;
&lt;/ul&gt;Lets have a look how to define and use an entity graph in JPA Modeler. &lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;h4 id=&quot;DIA&quot;&gt;Create the JPA Diagram :&lt;/h4&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Goto File menu &amp;gt; New File &amp;gt; Persistence category.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYdYBst3EQIZWRWrPRRkn6kisdOMtkQbhneFq-A0BZjO94WV8jLDAHd6ZCASXU8ppP9kWQ65khVBLnodjcTeXB7Qi757_rh0CuwpTcZ4LeIEgm5Su8Va8BzAu8TjNggXWB_twgVftgMBY/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYdYBst3EQIZWRWrPRRkn6kisdOMtkQbhneFq-A0BZjO94WV8jLDAHd6ZCASXU8ppP9kWQ65khVBLnodjcTeXB7Qi757_rh0CuwpTcZ4LeIEgm5Su8Va8BzAu8TjNggXWB_twgVftgMBY/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Select JPA Diagram&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;From the Persistence , select JPA Diagram and click Next.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Type&amp;nbsp;&lt;b&gt;SampleDiagram&amp;nbsp;&lt;/b&gt;for the diagram name.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Type&amp;nbsp;&lt;b&gt;com.jpamodeler.entitygraph&lt;/b&gt;&amp;nbsp;for the Package.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Click Finish.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;When you click Finish, the IDE creates the JPA Diagram and opens the diagram in the designer window.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;CRE&quot;&gt;Create the Entities:&lt;/h4&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Drag &amp;amp; Drop the Entities&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot; /&gt;&lt;/a&gt;&amp;nbsp;from the Palette window to designer.&amp;nbsp;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY9EOTiSQkt6GPzqHB_Q4PxI9Ijr4x2kaoUHLlc8zMoAJhWpBfOwk7TUlIXzKPLlTyKUeYDOt_vQ-O1svRBA_fAlagKGtOgl2ROc4n5ZIhGYvyyOF5IrywtpjjOt-0D3df-QlaxcEW3qA/s1600/pal.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY9EOTiSQkt6GPzqHB_Q4PxI9Ijr4x2kaoUHLlc8zMoAJhWpBfOwk7TUlIXzKPLlTyKUeYDOt_vQ-O1svRBA_fAlagKGtOgl2ROc4n5ZIhGYvyyOF5IrywtpjjOt-0D3df-QlaxcEW3qA/s1600/pal.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;Palette&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Double click on the Entity and rename to &lt;b&gt;Movie&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;To create&amp;nbsp;&lt;b&gt;basic attribute&lt;/b&gt;,&amp;nbsp;click on the&amp;nbsp;&lt;b&gt;Movie &lt;/b&gt;Entity&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot; /&gt;&lt;/a&gt;&amp;nbsp;, then click on the expand&amp;nbsp;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxSOuKcY3d5Kmyr4bdTQ-LrcvdnLilN6lB2aJr6SUA2ZT8vEWv8GA6lNasr883Kh_nY9MblFm9XMCmGlHTHV80j1yzV68M-GEYYxceALUKO76PQHVSe3YpFiTFFpl4TVEtsjHnkraxDq0/s1600/add-element.png&quot; /&gt;&amp;nbsp;&amp;nbsp;button &amp;gt; basic&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-T3Sj_ULp_eZCzMNNdiDT0b3JoDpQaMRc2pNc-RGvaP4FMHCNz_KzUxQpo7uGlMbf5T-jmVSJbiWVokLBPzyD7RqAbUrcZwQuEfV3l2szrZHWd1oyDQfkhq7MHoHOACm2Q0tkr2ZVFXE/s1600/basic-attribute.png&quot; imageanchor=&quot;1&quot; style=&quot;margin: 0px;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-T3Sj_ULp_eZCzMNNdiDT0b3JoDpQaMRc2pNc-RGvaP4FMHCNz_KzUxQpo7uGlMbf5T-jmVSJbiWVokLBPzyD7RqAbUrcZwQuEfV3l2szrZHWd1oyDQfkhq7MHoHOACm2Q0tkr2ZVFXE/s1600/basic-attribute.png&quot; /&gt;&lt;/a&gt;&amp;nbsp;property.&lt;/li&gt;
&lt;li&gt;To create&amp;nbsp;&lt;b&gt;&lt;b&gt;relation&amp;nbsp;&lt;/b&gt;attribute&lt;/b&gt;, click on the&amp;nbsp;&lt;b&gt;Movie&amp;nbsp;&lt;/b&gt;Entity&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot; /&gt;&lt;/a&gt;.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9xVJZbLEJ70d6fZGVqrWFkyTbtx7M5UNGS3SqCE4XbbgtkWM_9f9QR2G_NgDpoeWTvYEL2tnWuAbH7nKi2HtgBHNVkTO9n07fzxp7LtvJwxENK7Uxm28ENrkhyC8kEOU6n2QRIlH-nNQ/s1600/12.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9xVJZbLEJ70d6fZGVqrWFkyTbtx7M5UNGS3SqCE4XbbgtkWM_9f9QR2G_NgDpoeWTvYEL2tnWuAbH7nKi2HtgBHNVkTO9n07fzxp7LtvJwxENK7Uxm28ENrkhyC8kEOU6n2QRIlH-nNQ/s1600/12.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 12.8px;&quot;&gt;Add relation property&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Now, drag OneToMany&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJkiFtOavtJEHbJU76vTBDp-Fe3eNVYfYmHmgqheOJej_4DYcm3f6D_H7hwhE-QZfT4VjiO-2uG4HoAZQ5O7MtbfLeR6WPThaGUvwi5u6LNira2NVRcvrNu6KMo5ueIp-gLGO39oMH7SI/s1600/one-to-many.gif&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJkiFtOavtJEHbJU76vTBDp-Fe3eNVYfYmHmgqheOJej_4DYcm3f6D_H7hwhE-QZfT4VjiO-2uG4HoAZQ5O7MtbfLeR6WPThaGUvwi5u6LNira2NVRcvrNu6KMo5ueIp-gLGO39oMH7SI/s1600/one-to-many.gif&quot; /&gt;&lt;/a&gt;&amp;nbsp;attribute&amp;nbsp;to&amp;nbsp;&lt;b&gt;MovieActor &lt;/b&gt;Entity&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot; /&gt;&lt;/a&gt;&amp;nbsp;class.   &lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-ZgOUGxrWaFwL46NzXv3vIKTMC7aMI4JI_YF5HJsef_Cv-Irw4GFrEd3iLcG0pLDbsX8izVVvMI2e7vwrYqn2Lj6my7NXzvMs91h8GewCAbVxZJrNTKCeRQu_OMNFQVfRL_KbAsUHyrs/s1600/13.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-ZgOUGxrWaFwL46NzXv3vIKTMC7aMI4JI_YF5HJsef_Cv-Irw4GFrEd3iLcG0pLDbsX8izVVvMI2e7vwrYqn2Lj6my7NXzvMs91h8GewCAbVxZJrNTKCeRQu_OMNFQVfRL_KbAsUHyrs/s1600/13.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Relation property&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLKvKGnnSo2rrh5bDbXeE-efr1hkMrtXn3jaPTulIPoAzfCdgJjQFEUPPMadSR842TCSDV5LJmXhKxnY9E72T-c4f2JfHu8P1GPeIFDoqUHH6xcJMsvYJ3UNrOkF3781L-342-21T1eu0/s1600/14.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLKvKGnnSo2rrh5bDbXeE-efr1hkMrtXn3jaPTulIPoAzfCdgJjQFEUPPMadSR842TCSDV5LJmXhKxnY9E72T-c4f2JfHu8P1GPeIFDoqUHH6xcJMsvYJ3UNrOkF3781L-342-21T1eu0/s1600/14.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Final design&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;h4 id=&quot;CEG&quot; style=&quot;text-align: left;&quot;&gt;Create the @NamedEntityGrpah :&lt;/h4&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/NamedEntityGraph.html&quot; target=&quot;_blank&quot;&gt;NamedEntityGraph&lt;/a&gt;&lt;/code&gt; defines a unique name and a list of attributes ( the &lt;code&gt;&lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/NamedEntityGraph.html#attributeNodes--&quot; target=&quot;_blank&quot;&gt;attributeNodes&lt;/a&gt;&lt;/code&gt; ) that have be loaded.&lt;/blockquote&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;
&lt;li style=&quot;font-weight: normal;&quot;&gt;Click on the entity &amp;gt; Properties.&lt;/li&gt;
&lt;li style=&quot;font-weight: normal;&quot;&gt;From the properties, select&amp;nbsp;&lt;b&gt;Named Entity Graphs &lt;/b&gt;Property.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipBd79a5AUf562Oi2I4t9diq44O-EM_dJBoOgocVgedhBXMWjOT1Ibh_zc3tkhuVlabQvEQEy5C1Pz7rxXfvPYhmclWxhzE8vQoveAazd0CCQ4YLvU_K6LYfX5QX9cd0atW4jzSu1psUw/s1600/15.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipBd79a5AUf562Oi2I4t9diq44O-EM_dJBoOgocVgedhBXMWjOT1Ibh_zc3tkhuVlabQvEQEy5C1Pz7rxXfvPYhmclWxhzE8vQoveAazd0CCQ4YLvU_K6LYfX5QX9cd0atW4jzSu1psUw/s1600/15.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Open Entity Graph Panel&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Click on the &lt;/span&gt;&lt;b&gt;Add button&lt;/b&gt; to create new named entity graph.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;font-weight: normal; margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNpDA4X1QfYd72jbz9C-OPmxy8biE7LfLhtX3CMevcD01aeAeoi0ZY_zzO3Sk4_S-QF9NcNLJ8CD9TzzCJ6MFZZ5zo8X_Oor2y6hvrlIVMgtji-0GLk-NVGeeIs0O4aFsSh-1vwS3EzHk/s1600/16.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNpDA4X1QfYd72jbz9C-OPmxy8biE7LfLhtX3CMevcD01aeAeoi0ZY_zzO3Sk4_S-QF9NcNLJ8CD9TzzCJ6MFZZ5zo8X_Oor2y6hvrlIVMgtji-0GLk-NVGeeIs0O4aFsSh-1vwS3EzHk/s1600/16.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Create Entity Grpah&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-weight: normal; text-align: center;&quot;&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal;&quot;&gt;In this panel , you may view entity attributes with check-box in the tree structure.&amp;nbsp;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgvhJVE9nA7rc0U3j9YZUsMnsZTrm8sXsODqfOaQThLT8xthjOBwoYkzdhd_GhC3XBYz2z52Z3roc6H2kjgweM4tZYdGVMaOfg_siYa6TVngmS6Ty3QKrHAIMBl6z3m0GbYW4zg_LnffY/s1600/17.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgvhJVE9nA7rc0U3j9YZUsMnsZTrm8sXsODqfOaQThLT8xthjOBwoYkzdhd_GhC3XBYz2z52Z3roc6H2kjgweM4tZYdGVMaOfg_siYa6TVngmS6Ty3QKrHAIMBl6z3m0GbYW4zg_LnffY/s1600/17.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Entity Graph editor&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal;&quot;&gt;Select the attribute from the tree to add the fields to the entity graph which will be part of &lt;code&gt;attributeNodes&lt;/code&gt; element of &lt;code&gt;@NamedEntityGraph&lt;/code&gt; with a &lt;code&gt;javax.persistence.NamedAttributeNode&lt;/code&gt; annotation and then, type the entity graph name.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0N2-3cX0M5AAcXRVJ3KRORNxqyUpzxSX7H6rouEM_f8yOxu-YZxDcZxhqXdtw71KIm5iTXx8U1SW-4rgaBHSUNIUXf_uVcKRgWQpuoc24a6D9Z0xAQvVqPF9YkUhvJjzQYm7F4U_Fiuk/s1600/18.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0N2-3cX0M5AAcXRVJ3KRORNxqyUpzxSX7H6rouEM_f8yOxu-YZxDcZxhqXdtw71KIm5iTXx8U1SW-4rgaBHSUNIUXf_uVcKRgWQpuoc24a6D9Z0xAQvVqPF9YkUhvJjzQYm7F4U_Fiuk/s1600/18.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;select attributes&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li style=&quot;font-weight: normal;&quot;&gt;In this example, the name of the named entity graph is &lt;b&gt;movieWithActorsAndAwards&lt;/b&gt; and include the &lt;b&gt;movieActors&lt;/b&gt; field.&lt;/li&gt;
&lt;li style=&quot;font-weight: normal;&quot;&gt;Click on the save button to save named entity graph.  &lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBQ1VS87F5V3Jb1VDJjbB230lf6wHZcsX4foQucP4XzogW8mhVypIQzNyoNyzTKUFYtpidneRt7nYhfz8-UTZ9sKwgoJnynoOapC6BgRv7yMjFRBokLvTXDS6quqdHwONFVxxwIT1n_vI/s1600/21.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBQ1VS87F5V3Jb1VDJjbB230lf6wHZcsX4foQucP4XzogW8mhVypIQzNyoNyzTKUFYtpidneRt7nYhfz8-UTZ9sKwgoJnynoOapC6BgRv7yMjFRBokLvTXDS6quqdHwONFVxxwIT1n_vI/s1600/21.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Created Entity Graph&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;h4 id=&quot;NES&quot;&gt;Named sub graph :&lt;/h4&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;The definition of a named sub graph is similar to the definition of an named entity graph and can be referenced as an attributeNode.&lt;/blockquote&gt;We used the entity graph to define the fetch operation of the Movie entity. If we want to do the same for the &lt;b&gt;MovieActor&lt;/b&gt; entity, we can do this with an entity sub graph.&lt;br /&gt;
Now, we will edit the entity graph, expand the &lt;b&gt;movieActors&lt;/b&gt; attribute and then select the &lt;b&gt;movieActorAwards&lt;/b&gt; attribute.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp15ra2xFxvU16uAuhEptT4vaqiz5j6MtFZkR7q9dsG7tGIfhV5sQXbwNrVgR-blRGIYyKzdKjgu_GYYgvhmjO7cJeWbB1rHTJbTyy_qU2_DeSvxymMOI07HnFPBiHsUyMHCxHh3q_VtY/s1600/19.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp15ra2xFxvU16uAuhEptT4vaqiz5j6MtFZkR7q9dsG7tGIfhV5sQXbwNrVgR-blRGIYyKzdKjgu_GYYgvhmjO7cJeWbB1rHTJbTyy_qU2_DeSvxymMOI07HnFPBiHsUyMHCxHh3q_VtY/s1600/19.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot;&gt;design Sub Entity Graph&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;The following code snippets shows the definition of a sub graph to load the &lt;i&gt;MovieActorAward&lt;/i&gt; of each &lt;b&gt;MovieActor&lt;/b&gt;. The defined entity graph will fetch an&amp;nbsp;&lt;b&gt;Movie&lt;/b&gt;&amp;nbsp;with all&amp;nbsp;&lt;i&gt;MovieActors&lt;/i&gt;&amp;nbsp;and their &lt;i&gt;MovieActorAwards&lt;/i&gt;.&lt;script src=&quot;https://gist.github.com/jShiwaniGupta/ff292e0a9f975219bb91.js&quot;&gt;&lt;/script&gt; &lt;br /&gt;
&lt;h4 id=&quot;EGT&quot;&gt;View the Entity Graph based on Graph Type :&lt;/h4&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;An entity graph can be used as a fetch or a load graph.&amp;nbsp;&lt;/blockquote&gt;To check the final view of entity graph based on the graph type on the &lt;b&gt;View button&lt;/b&gt;, after selection of attribute.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIPfmyeKIoknfbu4DB8_swVMhlDpnuyyP9QO9wsxWRVIbAvWySCkWCKSV15LSBs8D9b-KsrRFWCWU47RA0QZyYqe15w90_AK4SgAHRiLSkXpkY0kAi8dK0q36DbgrL20HGcd18vFF5NYI/s1600/3.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIPfmyeKIoknfbu4DB8_swVMhlDpnuyyP9QO9wsxWRVIbAvWySCkWCKSV15LSBs8D9b-KsrRFWCWU47RA0QZyYqe15w90_AK4SgAHRiLSkXpkY0kAi8dK0q36DbgrL20HGcd18vFF5NYI/s1600/3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul&gt;&lt;li&gt;If a &lt;b&gt;fetch graph&lt;/b&gt; is used, only the attributes specified by the entity graph will be treated as &lt;code&gt;&lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/FetchType.html#EAGER&quot; target=&quot;_blank&quot;&gt;FetchType.EAGER&lt;/a&gt;&lt;/code&gt; and all other attributes will be lazy.&amp;nbsp;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0So5pmkXuCy1L7h8kwj97DDjgDJQkQx7Ii7YQ0A3WEPfXbZTILxsqoohgY2PHUtNebCX4fQULN10F3Qi7o_dkMJB2OD_pAH-FVTL1X5ItKSpO5cVerKR8FAp6kYQqwJ9S9AxY6byHXF4/s1600/23.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0So5pmkXuCy1L7h8kwj97DDjgDJQkQx7Ii7YQ0A3WEPfXbZTILxsqoohgY2PHUtNebCX4fQULN10F3Qi7o_dkMJB2OD_pAH-FVTL1X5ItKSpO5cVerKR8FAp6kYQqwJ9S9AxY6byHXF4/s1600/23.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Fetch Graph&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;If a &lt;b&gt;load graph&lt;/b&gt; is used, all attributes that are not specified by the entity graph will keep their default fetch type.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUzo2TKhD65wXQ1JLkWI53NY21i4-P4qOSdb-XTjq4KI_f313VPpgr_1KoM3Piiva4ysHcuWV-daIruciEkkwu3E5SPTLcmaI3kM-lMOoTkEsqiqRZiAO4nU31SyrHljQfuTZQF30KFf4/s1600/24.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUzo2TKhD65wXQ1JLkWI53NY21i4-P4qOSdb-XTjq4KI_f313VPpgr_1KoM3Piiva4ysHcuWV-daIruciEkkwu3E5SPTLcmaI3kM-lMOoTkEsqiqRZiAO4nU31SyrHljQfuTZQF30KFf4/s1600/24.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Load Graph&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;/ul&gt;Entity graphs have attributes that correspond to the fields that will be eagerly fetched during a &lt;code&gt;find&lt;/code&gt; or query operation. The primary key and version fields of the entity class are always fetched and do not need to be explicitly added to an entity graph.  &lt;br /&gt;
&lt;h4 id=&quot;GSRC&quot;&gt;Generate the entity classes :&lt;/h4&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Right click on the diagram &amp;gt; Generate Source Code.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge1zz_z4U5BFDJghFvsCliSlB9m8xQRrkydtkLLTeKBghqquKjzEQsIZ-on-YhqgGUIPSKMA9TILMUU2s7jXeGo2Pc1uDVYyN6BlcoI2w8VbKfTHdqkoorqxqLgz-Alesn2p03El0aupI/s1600/22.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge1zz_z4U5BFDJghFvsCliSlB9m8xQRrkydtkLLTeKBghqquKjzEQsIZ-on-YhqgGUIPSKMA9TILMUU2s7jXeGo2Pc1uDVYyN6BlcoI2w8VbKfTHdqkoorqxqLgz-Alesn2p03El0aupI/s1600/22.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Generate Source Code&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Click on the Movie entity class to view source code.&amp;nbsp;&lt;script src=&quot;https://gist.github.com/jShiwaniGupta/eeef86748727574e80ae.js&quot;&gt;&lt;/script&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;h4 id=&quot;EGI&quot;&gt;Obtaining EntityGraph Instances from Named Entity Graphs:&lt;/h4&gt;Use the &lt;code&gt;&lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/EntityManager.html#createEntityGraph-java.lang.String-&quot; target=&quot;_blank&quot;&gt;EntityManager.getEntityGraph&lt;/a&gt;&lt;/code&gt; method, passing in the named entity graph name, to obtain &lt;code&gt;&lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/EntityGraph.html&quot; target=&quot;_blank&quot;&gt;EntityGraph&lt;/a&gt;&lt;/code&gt; instances:&lt;br /&gt;
&lt;pre class=&quot;oac_no_warn&quot; dir=&quot;ltr&quot; style=&quot;background-color: #efefef; border-radius: 5px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: monospace, serif; font-size: 13px; line-height: 20px; margin-bottom: 1em; margin-top: 1em; overflow: auto; padding: 8px; white-space: pre-wrap; word-wrap: break-word;&quot; xml:space=&quot;preserve&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;EntityGraph&lt;emailmessage&gt; eg = em.getEntityGraph(&quot;movieWithActorsAndAwards&quot;);&lt;/emailmessage&gt;&lt;/span&gt;&lt;/pre&gt;You can use an entity graph with the &lt;code&gt;EntityManager.find&lt;/code&gt; method or as part of a &lt;code&gt;JPQL&lt;/code&gt; or &lt;code&gt;Criteria API&lt;/code&gt; query by specifying the entity graph as a hint to the operation or query.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;EGQ&quot;&gt;Using Entity Graphs in Query Operations:&lt;/h4&gt;Now that we have defined the entity graph, we can use it in a query. To specify entity graphs for both typed and untyped queries, call the &lt;code&gt;setHint&lt;/code&gt; method on the query object and specify either &lt;code&gt;javax.persistence.loadgraph&lt;/code&gt; or &lt;code&gt;javax.persistence.fetchgraph&lt;/code&gt; as the property name and an EntityGraph instance as the value.&lt;br /&gt;
The following code snippet shows how to use a named entity graph as a fetch graph in a find statement :&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/jShiwaniGupta/20b0772ed7b21d9abaa3.js&quot;&gt;&lt;/script&gt; In this example, the &lt;b&gt;movieWithActorsAndAwards&lt;/b&gt; is used for the &lt;b&gt;Movie.findAll&lt;/b&gt; named query and we provide this graph as a hint to the entity manager, to fetch the movies and all their actors in one query.&lt;br /&gt;
&lt;h4 id=&quot;DSRC&quot;&gt;Download Source Code :&amp;nbsp;&lt;/h4&gt;&lt;a href=&quot;https://github.com/jShiwaniGupta/JPA-Modeler-Example/tree/master/Named%20Entity%20Graph&quot; target=&quot;_blank&quot;&gt;Github - Named Entity Graph&lt;/a&gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;CON&quot;&gt;Conclusion:&lt;/h4&gt;The Entity Graph overrides the default loading strategy, and provides flexibility of loading the association &amp;amp; attributes of an Entity and helps to improve the performance of application. The usage and definition of the entity graph does not depends on query and we can fetch a graph of multiple entities with only one select query, so the main drawbacks of the JPA 2.0 are solved. &lt;br /&gt;
The Above example shows a very simple entity graph and you will probably be using more complex graphs in a real application which may have &lt;b&gt;more annotations than actual code&lt;/b&gt; and that would make the code harder to read, so the JPA Modeler assist the developer to design &amp;amp; manage the entity graph and generate &amp;amp; reverse-engineering the annotation by modeler.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://jpamodeler.blogspot.com/feeds/1084100328668806806/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1110200500196347069/1084100328668806806' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1110200500196347069/posts/default/1084100328668806806'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1110200500196347069/posts/default/1084100328668806806'/><link rel='alternate' type='text/html' href='http://jpamodeler.blogspot.com/2015/12/namedentitygraph.html' title='@NamedEntityGraph in Action'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/16315177036314487677</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYdYBst3EQIZWRWrPRRkn6kisdOMtkQbhneFq-A0BZjO94WV8jLDAHd6ZCASXU8ppP9kWQ65khVBLnodjcTeXB7Qi757_rh0CuwpTcZ4LeIEgm5Su8Va8BzAu8TjNggXWB_twgVftgMBY/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1110200500196347069.post-7243110641633176485</id><published>2015-11-30T17:23:00.000-08:00</published><updated>2016-04-07T20:51:30.725-07:00</updated><title type='text'>Sponsor</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If your company needs a particular feature or changes added to JPA Modeler, wants to obtain priority support for JPA Modeler, or just would like to help make sure JPA Modeler thrives through continued enhancements, &lt;a href=&quot;mailto:jShiwaniGupta@gmail.com&quot;&gt;email Shiwani Gupta&lt;/a&gt; to find out about rates for JPA Modeler-related services.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;script&gt;window.location.href=&quot;http://jpamodeler.github.io&quot;&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://jpamodeler.blogspot.com/feeds/7243110641633176485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1110200500196347069/7243110641633176485' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1110200500196347069/posts/default/7243110641633176485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1110200500196347069/posts/default/7243110641633176485'/><link rel='alternate' type='text/html' href='http://jpamodeler.blogspot.com/2015/11/sponsors.html' title='Sponsor'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/16315177036314487677</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1110200500196347069.post-7087172625220638694</id><published>2015-11-30T02:21:00.000-08:00</published><updated>2016-04-07T20:50:57.227-07:00</updated><title type='text'>@Embeddable Classes in Action</title><content type='html'>&lt;script&gt;window.location.href=&quot;http://jpamodeler.github.io/tutorial/page.html?l=Embeddable&quot;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;script&gt;window.location.href=&quot;http://jpamodeler.github.io/tutorial/page.html?l=Embeddable&quot;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3 id=&quot;TOC&quot; style=&quot;text-align: left;&quot;&gt;Table of Content :&lt;/h3&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;#INT&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#DIA&quot;&gt;Create the JPA Diagram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#EMB&quot;&gt;Create the Embedded Property&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#NES&quot;&gt;Nested Embeddable Classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#SH&quot;&gt;Shared Embeddable&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#RES&quot;&gt;Restriction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#SRC&quot;&gt;Source Code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;h4 id=&quot;INT&quot; style=&quot;text-align: left;&quot;&gt;Introduction :&lt;/h4&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;JPA allows the persistence of fields as embedded typically into the same table as the &quot;owning&quot; class using&amp;nbsp;&lt;a href=&quot;https://docs.oracle.com/javaee/7/api/javax/persistence/Embedded.html&quot; target=&quot;_blank&quot;&gt;@Embedded&lt;/a&gt; objects, which allow you to pull out attributes of an entity into another class, and embed that class back into the entity. The result is a Java object that might look a little more logical, but doesn’t actually change the database structure since the embedded object’s fields are still on the first object.&lt;/blockquote&gt;&lt;br /&gt;
To illustrate this, imagine we have a Person object who has an Address.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDxBLafSZDp3LwXHb9KXCOFaCKBw3hOCyFf4sL4i-wMS5nsOt5v85qAmiJTk9AW8H8ewZy0g5UWS2gfGfh_NUMYw0ytWNyj2zJ6QC8hxB5VejLwCQx4susUbqK-8onqPZNIWLr7OcDpS4/s1600/ent.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDxBLafSZDp3LwXHb9KXCOFaCKBw3hOCyFf4sL4i-wMS5nsOt5v85qAmiJTk9AW8H8ewZy0g5UWS2gfGfh_NUMYw0ytWNyj2zJ6QC8hxB5VejLwCQx4susUbqK-8onqPZNIWLr7OcDpS4/s1600/ent.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Person Entity with address fields&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
It might make sense to pull out the address into another class, but maybe for speed or legacy reasons we have to keep a denormalized table structure. Using an Embeddable class (with the &lt;a href=&quot;https://docs.oracle.com/javaee/7/api/javax/persistence/Embeddable.html&quot; target=&quot;_blank&quot;&gt;@Embeddable&lt;/a&gt; annotation), we can still do this on the JPA end of things. It would look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-AwigQDvV4n9CLTWqIogC82ml1QUlKVwH-wLg4XpcPeNN3Vd8GzXukOxeBolf9PkOcFi9ZbKM67nDkLizlpseGGiEWk2-vwZHgAr3f67IN7EC1nRysIpeBFftNopG-SZ-MZ1KtmzlDQM/s1600/embed.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-AwigQDvV4n9CLTWqIogC82ml1QUlKVwH-wLg4XpcPeNN3Vd8GzXukOxeBolf9PkOcFi9ZbKM67nDkLizlpseGGiEWk2-vwZHgAr3f67IN7EC1nRysIpeBFftNopG-SZ-MZ1KtmzlDQM/s1600/embed.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 12.8px;&quot;&gt;Person Entity and Address Embeddable&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;Instances of embeddable classes are always embedded in other entity objects and do not require separate space allocation and separate store and retrieval operations. Therefore, using embeddable classes can save space in the database and improve efficiency.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;DIA&quot; style=&quot;text-align: left;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Create the JPA Diagram :&lt;/h4&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Goto File menu &amp;gt; New File &amp;gt; Persistence category .&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBbLy7AI-3n5HWGQ5ZiqA2l39oExQj-0BsuAVY-_qXtcGXCW2rPawMvNeEYWKlscuMZW5lDnLdQzAe1Z0M6C_fW3Irks5YUI2nU1cZFeADkFcnqXxXJ0Gb7gigkfMFG5XbYk862DTve6Q/s1600/0.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBbLy7AI-3n5HWGQ5ZiqA2l39oExQj-0BsuAVY-_qXtcGXCW2rPawMvNeEYWKlscuMZW5lDnLdQzAe1Z0M6C_fW3Irks5YUI2nU1cZFeADkFcnqXxXJ0Gb7gigkfMFG5XbYk862DTve6Q/s1600/0.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Create JPA Diagram&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;From the Persistence , select JPA Diagram and click Next.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Type &lt;b&gt;SmapleERD &lt;/b&gt;for the diagram name.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Type &lt;b&gt;com.jpamodeler.embeddable&lt;/b&gt; for the Package.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Click Finish.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;When we click Finish, the NetBeans IDE creates the JPA Diagram and opens the diagram in the designer window.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;EMB&quot; style=&quot;text-align: left;&quot;&gt;Create the Embedded Property:&lt;/h4&gt;&lt;div&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;The &lt;b&gt;&lt;a href=&quot;https://docs.oracle.com/javaee/7/api/javax/persistence/Embedded.html&quot; target=&quot;_blank&quot;&gt;@Embedded&lt;/a&gt;&lt;/b&gt; annotation is used to specify a persistent field or property of an entity whose value is an instance of an embeddable class. A class is declared as embeddable by marking it with the&amp;nbsp;&lt;b&gt;&lt;a href=&quot;https://docs.oracle.com/javaee/7/api/javax/persistence/Embeddable.html&quot; target=&quot;_blank&quot;&gt;@&lt;/a&gt;&lt;/b&gt;&lt;b&gt;&lt;a href=&quot;https://docs.oracle.com/javaee/7/api/javax/persistence/Embeddable.html&quot; target=&quot;_blank&quot;&gt;Embeddable&lt;/a&gt;&amp;nbsp;&lt;/b&gt;annotation.&amp;nbsp;&lt;/blockquote&gt;&lt;/div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Drag &amp;amp; Drop the Entity &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot; /&gt;&lt;/a&gt; and Embeddable &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot; /&gt;&lt;/a&gt; from the Palette window to designer.&amp;nbsp;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY9EOTiSQkt6GPzqHB_Q4PxI9Ijr4x2kaoUHLlc8zMoAJhWpBfOwk7TUlIXzKPLlTyKUeYDOt_vQ-O1svRBA_fAlagKGtOgl2ROc4n5ZIhGYvyyOF5IrywtpjjOt-0D3df-QlaxcEW3qA/s1600/pal.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY9EOTiSQkt6GPzqHB_Q4PxI9Ijr4x2kaoUHLlc8zMoAJhWpBfOwk7TUlIXzKPLlTyKUeYDOt_vQ-O1svRBA_fAlagKGtOgl2ROc4n5ZIhGYvyyOF5IrywtpjjOt-0D3df-QlaxcEW3qA/s1600/pal.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Palette&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Double click on the Entity and Embeddable and rename to Person and Address .&amp;nbsp;&lt;/li&gt;
&lt;li&gt;To create &lt;b&gt;basic attribute&lt;/b&gt;,&amp;nbsp;click on the&amp;nbsp;&lt;b&gt;Person Entity&amp;nbsp;&lt;/b&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot; /&gt;&lt;/a&gt;&amp;nbsp;, then click on the expand&amp;nbsp;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxSOuKcY3d5Kmyr4bdTQ-LrcvdnLilN6lB2aJr6SUA2ZT8vEWv8GA6lNasr883Kh_nY9MblFm9XMCmGlHTHV80j1yzV68M-GEYYxceALUKO76PQHVSe3YpFiTFFpl4TVEtsjHnkraxDq0/s1600/add-element.png&quot; /&gt; &amp;nbsp;button &amp;gt; basic&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-T3Sj_ULp_eZCzMNNdiDT0b3JoDpQaMRc2pNc-RGvaP4FMHCNz_KzUxQpo7uGlMbf5T-jmVSJbiWVokLBPzyD7RqAbUrcZwQuEfV3l2szrZHWd1oyDQfkhq7MHoHOACm2Q0tkr2ZVFXE/s1600/basic-attribute.png&quot; imageanchor=&quot;1&quot; style=&quot;margin: 0px;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-T3Sj_ULp_eZCzMNNdiDT0b3JoDpQaMRc2pNc-RGvaP4FMHCNz_KzUxQpo7uGlMbf5T-jmVSJbiWVokLBPzyD7RqAbUrcZwQuEfV3l2szrZHWd1oyDQfkhq7MHoHOACm2Q0tkr2ZVFXE/s1600/basic-attribute.png&quot; /&gt;&lt;/a&gt;&amp;nbsp;property.&lt;/li&gt;
&lt;li&gt;To create &lt;b&gt;embedded&amp;nbsp;attribute&lt;/b&gt;, click on the &lt;b&gt;Person Entity &lt;/b&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-QW2ZtpZqLli1manUupLAhVCTmLRxhshZgMOGOWZxPrvYy__pi31oOiTlCu0g4A6yjtrUFRcE7j12dJAonQyCmAsw7FlWzfo2DgmquUKXYKX5yBQgyl7s91Gw_Fe4HrR-KNUU11GvgI0/s1600/ENTITY.png&quot; /&gt;&lt;/a&gt; , then click on the composition &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid5TRKb1kq9j2UMZ4HEqbV-kBkrhYR2Qp9BQQBV6iNw0Zo3N9ItT4P5F5NY_CRl49xv-TVjkJI3qG02BU4OaG5xrUgvXctptVaTTDt-M-c1IzXDbf2o8WEs3vHWYYSO7c3nNyaAPPBbjg/s1600/composition.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid5TRKb1kq9j2UMZ4HEqbV-kBkrhYR2Qp9BQQBV6iNw0Zo3N9ItT4P5F5NY_CRl49xv-TVjkJI3qG02BU4OaG5xrUgvXctptVaTTDt-M-c1IzXDbf2o8WEs3vHWYYSO7c3nNyaAPPBbjg/s1600/composition.png&quot; /&gt;&lt;/a&gt; button.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4blqxz3kMaiRBJCnM8U85XS8VsZqulFUbz0SNQUOmaxNkJ_adKfS5PNSXiG5ewKRgdIcVFjTfGe3hthhLCMRbONgD5DFdKoSTZRHgxO83DZ5fvZ0gDqMhwAZcWwwTdWd0qLJGQdLu3UY/s1600/1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4blqxz3kMaiRBJCnM8U85XS8VsZqulFUbz0SNQUOmaxNkJ_adKfS5PNSXiG5ewKRgdIcVFjTfGe3hthhLCMRbONgD5DFdKoSTZRHgxO83DZ5fvZ0gDqMhwAZcWwwTdWd0qLJGQdLu3UY/s1600/1.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Add embedded property&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Now, drag embedded attribute &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAmfDbDvWieXmjvrUY-jZOvJi0qoBtlY1QhScwQDwd6Lb1NWi8DW9Qo6RAQmiUH90RZusfKHKDM6a4uU4oiVKfioWf56JkbDwsihKznZ0WFQQaQ0tCUfCOZFxA5DdWgbj3QJpYn9b4zEo/s1600/embedded-attribute.gif&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAmfDbDvWieXmjvrUY-jZOvJi0qoBtlY1QhScwQDwd6Lb1NWi8DW9Qo6RAQmiUH90RZusfKHKDM6a4uU4oiVKfioWf56JkbDwsihKznZ0WFQQaQ0tCUfCOZFxA5DdWgbj3QJpYn9b4zEo/s1600/embedded-attribute.gif&quot; /&gt;&lt;/a&gt; to &lt;b&gt;Address &lt;/b&gt;Embeddable &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot; /&gt;&lt;/a&gt; class.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZlljO_ZeysMlXKRE2gM4X9q6NSV_kJn4MKz77RF5ON8l7Ub-UucFaAjjMCQEY2AQm60c6zRfU0XGEMNwHmh7Vh7OsQEm9zwmevnllpgBS95hylFGMTIYnOaWiwSPnMvfGl2odlsu1Xzg/s1600/2.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZlljO_ZeysMlXKRE2gM4X9q6NSV_kJn4MKz77RF5ON8l7Ub-UucFaAjjMCQEY2AQm60c6zRfU0XGEMNwHmh7Vh7OsQEm9zwmevnllpgBS95hylFGMTIYnOaWiwSPnMvfGl2odlsu1Xzg/s1600/2.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Embedded property&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Right click on the diagram &amp;gt; Generate Source Code.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJbiuFM41UQeZrawetFCavUTqbZpd_uECgeOC2TrOSH-490C2Inv419PDxEmrD0hFovaNgy9Cz7YVAE4V-raGPwbfTvDj6DdXXs6-KWa5Xf51Dk7T0B3iL9o19LuREpLOAcDp8ajWnHL4/s1600/Gene.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJbiuFM41UQeZrawetFCavUTqbZpd_uECgeOC2TrOSH-490C2Inv419PDxEmrD0hFovaNgy9Cz7YVAE4V-raGPwbfTvDj6DdXXs6-KWa5Xf51Dk7T0B3iL9o19LuREpLOAcDp8ajWnHL4/s1600/Gene.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Generate Source Code&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Click on the Person entity and Address embeddable class to view generated source code.&lt;script src=&quot;https://gist.github.com/jShiwaniGupta/e5810acfec061bbd3f8e.js&quot;&gt;&lt;/script&gt;&lt;/li&gt;
&lt;li&gt;Now, deploy the project and view the database table.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik_37qTOeIkW_s-VhQYPSCz6R-egd9kIFYQM8ZxlRS33XhJgOpRED6lDkv_rx1-fb2NW67yc448OU4wH-erNEgJz3pCZeF2CsObdLGeNu2GCpxfmJT-gH96HnaxjddME4DZ1eT8wXl5M4/s1600/2.5.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik_37qTOeIkW_s-VhQYPSCz6R-egd9kIFYQM8ZxlRS33XhJgOpRED6lDkv_rx1-fb2NW67yc448OU4wH-erNEgJz3pCZeF2CsObdLGeNu2GCpxfmJT-gH96HnaxjddME4DZ1eT8wXl5M4/s1600/2.5.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Database&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;JPA will just treat all of the attributes of &lt;b&gt;Address&amp;nbsp;&lt;/b&gt;as attributes of &lt;b&gt;Person&lt;/b&gt;, and it all works out. JPQL queries should change, but for the most part all of your Java code looks a lot more logical. None of your queries will have any joins.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;NES&quot; style=&quot;text-align: left;&quot;&gt;Nested Embeddable Classes :&lt;/h4&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;A nested embeddable is a relationship to an embeddable object from another embeddable.&lt;/blockquote&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Drag &amp;amp; Drop the Embeddable &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot; /&gt;&lt;/a&gt; from the Palette window to designer.&lt;/li&gt;
&lt;li&gt;To create nested embedded property.Click on the &lt;b&gt;Address &lt;/b&gt;Embeddable &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot; /&gt;&lt;/a&gt; , then click on the composition &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid5TRKb1kq9j2UMZ4HEqbV-kBkrhYR2Qp9BQQBV6iNw0Zo3N9ItT4P5F5NY_CRl49xv-TVjkJI3qG02BU4OaG5xrUgvXctptVaTTDt-M-c1IzXDbf2o8WEs3vHWYYSO7c3nNyaAPPBbjg/s1600/composition.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEid5TRKb1kq9j2UMZ4HEqbV-kBkrhYR2Qp9BQQBV6iNw0Zo3N9ItT4P5F5NY_CRl49xv-TVjkJI3qG02BU4OaG5xrUgvXctptVaTTDt-M-c1IzXDbf2o8WEs3vHWYYSO7c3nNyaAPPBbjg/s1600/composition.png&quot; /&gt;&lt;/a&gt; button.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCDvmIL1tsXEoGF7DZXNmQy5kzaWOudYpZoP7aoLdjRvzZ-PKnufWmGQ343ChWPlHPHmi6G7TsTy13PEslkj_g3UpAGvEYUM9FjJRsd1v3MRQbMUADtGRekb625piL0S7cJ2Ypw4B2Xls/s1600/4.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCDvmIL1tsXEoGF7DZXNmQy5kzaWOudYpZoP7aoLdjRvzZ-PKnufWmGQ343ChWPlHPHmi6G7TsTy13PEslkj_g3UpAGvEYUM9FjJRsd1v3MRQbMUADtGRekb625piL0S7cJ2Ypw4B2Xls/s1600/4.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Add nested embedded property&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Now, drag embedded attribute &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAmfDbDvWieXmjvrUY-jZOvJi0qoBtlY1QhScwQDwd6Lb1NWi8DW9Qo6RAQmiUH90RZusfKHKDM6a4uU4oiVKfioWf56JkbDwsihKznZ0WFQQaQ0tCUfCOZFxA5DdWgbj3QJpYn9b4zEo/s1600/embedded-attribute.gif&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAmfDbDvWieXmjvrUY-jZOvJi0qoBtlY1QhScwQDwd6Lb1NWi8DW9Qo6RAQmiUH90RZusfKHKDM6a4uU4oiVKfioWf56JkbDwsihKznZ0WFQQaQ0tCUfCOZFxA5DdWgbj3QJpYn9b4zEo/s1600/embedded-attribute.gif&quot; /&gt;&lt;/a&gt; to &lt;b&gt;ZipCode &lt;/b&gt;Embeddable &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot; /&gt;&lt;/a&gt; class.&amp;nbsp;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNHgxZGexKoY4yzBEBpz0iZqSpEwJ8iG-BM5A2c8qYi1N0jZbqgBEOxVdjyskrYXD8PI9FsEsyaPhVa7SbHVcxtVB94HRDhFgSyTWi4T8Als9WmmhUIcV7DqwPpqCX5ctwhiE8NG8DA4s/s1600/5.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNHgxZGexKoY4yzBEBpz0iZqSpEwJ8iG-BM5A2c8qYi1N0jZbqgBEOxVdjyskrYXD8PI9FsEsyaPhVa7SbHVcxtVB94HRDhFgSyTWi4T8Als9WmmhUIcV7DqwPpqCX5ctwhiE8NG8DA4s/s1600/5.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 12.8px;&quot;&gt;Nested embedded property&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Right click on the diagram &amp;gt;&amp;nbsp;Generate Source Code.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJbiuFM41UQeZrawetFCavUTqbZpd_uECgeOC2TrOSH-490C2Inv419PDxEmrD0hFovaNgy9Cz7YVAE4V-raGPwbfTvDj6DdXXs6-KWa5Xf51Dk7T0B3iL9o19LuREpLOAcDp8ajWnHL4/s1600/Gene.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJbiuFM41UQeZrawetFCavUTqbZpd_uECgeOC2TrOSH-490C2Inv419PDxEmrD0hFovaNgy9Cz7YVAE4V-raGPwbfTvDj6DdXXs6-KWa5Xf51Dk7T0B3iL9o19LuREpLOAcDp8ajWnHL4/s1600/Gene.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Generate Source Code&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Click on the &lt;b&gt;Address &lt;/b&gt;and &lt;b&gt;ZipCode&amp;nbsp;&lt;/b&gt;embeddable class to view generated source code.&lt;script src=&quot;https://gist.github.com/jShiwaniGupta/5cab20c379378f6de000.js&quot;&gt;&lt;/script&gt;&lt;/li&gt;
&lt;li&gt;Now, deploy the project and view the database table.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9S8Extwd8zja6kX2HrbKWfgYhdIoSpzfrCAAZbA4FZdxnqNtCyPTv0s7ooYEJxIVXZz1S5f_p5zR6G8cK6xpGmt85C2VEQt7DIrrn8xlhKXtj9kY_aFrp2OBak4XpH7QU6VeajFWiDfM/s1600/7.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9S8Extwd8zja6kX2HrbKWfgYhdIoSpzfrCAAZbA4FZdxnqNtCyPTv0s7ooYEJxIVXZz1S5f_p5zR6G8cK6xpGmt85C2VEQt7DIrrn8xlhKXtj9kY_aFrp2OBak4XpH7QU6VeajFWiDfM/s1600/7.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Database&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;SH&quot; style=&quot;text-align: left;&quot;&gt;Shared Embeddable :&lt;/h4&gt;&lt;blockquote&gt;An embeddable object can be shared between multiple classes or within class. By default, column definitions specified in the &lt;b&gt;&lt;a href=&quot;https://docs.oracle.com/javaee/7/api/javax/persistence/Embeddable.html&quot; target=&quot;_blank&quot;&gt;@Embeddable&lt;/a&gt;&lt;/b&gt; class apply to the table of the owning entity but you can override them using &lt;b&gt;@AttributeOverride&lt;/b&gt;.&lt;/blockquote&gt;&lt;br /&gt;
Consider &lt;b&gt;Person &lt;/b&gt;has property&lt;b&gt; home address&lt;/b&gt; and &lt;b&gt;office address &lt;/b&gt;of type Address. If Entity have the same embeddable object type twice, then default column name will not work, at least one of the columns will have to be explicit. To support this, @&lt;a href=&quot;https://java.sun.com/javaee/5/docs/api/javax/persistence/AttributeOverride.html&quot;&gt;AttributeOverride&lt;/a&gt; can be applied to an embedded field or property to override mapping defined by the embeddable class (or embeddable class of one of its attributes).&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;First rename the &lt;b&gt;address &lt;/b&gt;property to &lt;b&gt;homeAddress &lt;/b&gt;by double click on it.&lt;/li&gt;
&lt;li&gt;Drag embedded attribute &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAmfDbDvWieXmjvrUY-jZOvJi0qoBtlY1QhScwQDwd6Lb1NWi8DW9Qo6RAQmiUH90RZusfKHKDM6a4uU4oiVKfioWf56JkbDwsihKznZ0WFQQaQ0tCUfCOZFxA5DdWgbj3QJpYn9b4zEo/s1600/embedded-attribute.gif&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAmfDbDvWieXmjvrUY-jZOvJi0qoBtlY1QhScwQDwd6Lb1NWi8DW9Qo6RAQmiUH90RZusfKHKDM6a4uU4oiVKfioWf56JkbDwsihKznZ0WFQQaQ0tCUfCOZFxA5DdWgbj3QJpYn9b4zEo/s1600/embedded-attribute.gif&quot; /&gt;&lt;/a&gt; to &lt;b&gt;Address &lt;/b&gt;Embeddable &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3UmcvGqf1jAbcRrMmbf3yXHMfj1hWBH7ABEQiQBCO2dpAQVJDwNGMc9rSBaUc9BetfSGbxLXairopj9shXr6HZPYEJ1nXlqqPL08twFHPJ25EyfNaajRCf9B-hBWikz5wYEgfKuW1m3U/s1600/EMBEDDABLE.png&quot; /&gt;&lt;/a&gt; class , to add one more embedded property named &lt;b&gt;officeAddress&lt;/b&gt;.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGpKWETrW0mKhUhhW3C1TWYc4Zcdp0wi2zACT-xhrdQjJNfdF7Gd0yXLtKgABSATkzGqZ-xnWUno4qVFUmi2Y4LeRR_xx1NhbR9ICePnBAcdXPLiK3Sgz4mq9-soImyWBAPBiULzdtS5U/s1600/8.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGpKWETrW0mKhUhhW3C1TWYc4Zcdp0wi2zACT-xhrdQjJNfdF7Gd0yXLtKgABSATkzGqZ-xnWUno4qVFUmi2Y4LeRR_xx1NhbR9ICePnBAcdXPLiK3Sgz4mq9-soImyWBAPBiULzdtS5U/s1600/8.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;homeAddress and officeAddress property&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Right click on the diagram &amp;gt;&amp;nbsp;Generate Source Code.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJbiuFM41UQeZrawetFCavUTqbZpd_uECgeOC2TrOSH-490C2Inv419PDxEmrD0hFovaNgy9Cz7YVAE4V-raGPwbfTvDj6DdXXs6-KWa5Xf51Dk7T0B3iL9o19LuREpLOAcDp8ajWnHL4/s1600/Gene.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJbiuFM41UQeZrawetFCavUTqbZpd_uECgeOC2TrOSH-490C2Inv419PDxEmrD0hFovaNgy9Cz7YVAE4V-raGPwbfTvDj6DdXXs6-KWa5Xf51Dk7T0B3iL9o19LuREpLOAcDp8ajWnHL4/s1600/Gene.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Generate Source Code&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Click on the &lt;b&gt;Person&amp;nbsp;&lt;/b&gt;entity class to view generated source code.&lt;script src=&quot;https://gist.github.com/jShiwaniGupta/54f2c9dd9ac273e69f85.js&quot;&gt;&lt;/script&gt;&lt;/li&gt;
&lt;li&gt;Now, deploy the project and see the &lt;b&gt;server log &lt;/b&gt;.&lt;/li&gt;
&lt;/ol&gt;The person table has two attributes (&lt;b&gt;homeAddress.&lt;/b&gt;&lt;b&gt;street&amp;nbsp;&lt;/b&gt;and &lt;b&gt;officeAddress.&lt;/b&gt;&lt;b&gt;street&lt;/b&gt;) that both have the same column name (&lt;b&gt;“street”&lt;/b&gt;). We have to define different column names for homeAddress and officeAddress attributes. To do that, use &lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/AttributeOverride.html&quot;&gt;@AttributeOverride&lt;/a&gt; (and if our embedded object has a relationship to another entity, use &lt;a href=&quot;http://docs.oracle.com/javaee/7/api/javax/persistence/AssociationOverride.html&quot;&gt;@AssociationOverride&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;h5 style=&quot;text-align: left;&quot;&gt;Add AttributeOverride Annotation :&lt;/h5&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Open the diagram and click on the &lt;b&gt;Person &lt;/b&gt;Entity&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Now, open the &lt;b&gt;JPA Override View&lt;/b&gt; panel from Menu &amp;gt; Window &amp;gt; JPA Modeler &amp;gt; Override View.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8to7HppLF8eByovi1pP885ywG3-0XT3f2nhUF3OjqhDtMH3I1Zmvo6u6M01_ZRV5P5D4FyQTPkQ3G7t0bWnvxBEpbk8PIoFlHPAwRfuWfG5afpf3kkMnkH66O6uDXN7sKVZ288BMb1iU/s1600/override.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8to7HppLF8eByovi1pP885ywG3-0XT3f2nhUF3OjqhDtMH3I1Zmvo6u6M01_ZRV5P5D4FyQTPkQ3G7t0bWnvxBEpbk8PIoFlHPAwRfuWfG5afpf3kkMnkH66O6uDXN7sKVZ288BMb1iU/s1600/override.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;JPA Override View Panel&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;In this panel, you may view all of the attribute on which &lt;b&gt;Attribute Override&lt;/b&gt; and &lt;b&gt;Association Override&lt;/b&gt; annotation can be applied.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjsCoLjFov5e0a-oxQU2RRJ0pOtELCHLuTaDh90nFjJkaMu8OU5oQ0XDpvflVdEH1_zzUDuXkQoOgOswaU5uCu_GdJ1F9rMdsjohiIbRDrgyt7Oqg-DTJ0dWM24Sz8PYv9v8bLF0xvzFM/s1600/10.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjsCoLjFov5e0a-oxQU2RRJ0pOtELCHLuTaDh90nFjJkaMu8OU5oQ0XDpvflVdEH1_zzUDuXkQoOgOswaU5uCu_GdJ1F9rMdsjohiIbRDrgyt7Oqg-DTJ0dWM24Sz8PYv9v8bLF0xvzFM/s1600/10.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Change column name of homeAddress.street&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Click on the attribute and change their column name from property panel.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgttuf_sRm9Um1DTaSNeSd5fiqlHvjKG3L4RJ4M75_69x4DfUjiaqgcBUMuL7Q7X16TWJIDiDFDcPOW2N74lHSKGG2FRfJsf8ejB5wu8ZYrnXU7FjM8vqHYo_e6VxzXkn0cMGhVmst006U/s1600/11.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgttuf_sRm9Um1DTaSNeSd5fiqlHvjKG3L4RJ4M75_69x4DfUjiaqgcBUMuL7Q7X16TWJIDiDFDcPOW2N74lHSKGG2FRfJsf8ejB5wu8ZYrnXU7FjM8vqHYo_e6VxzXkn0cMGhVmst006U/s1600/11.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 12.8px;&quot;&gt;Change column name of officeAddress.street&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Generate the source code and view Person entity class .&lt;script src=&quot;https://gist.github.com/jShiwaniGupta/9b250f2cb36cbc2de901.js&quot;&gt;&lt;/script&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Now, deploy the project and view the database table .&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjBeGxa3eguHaT2QTyMpqsiQa25IVWSlr6LGaEFfOpQdaCQ2The_-_k5neLHXYK6EzyRldJ_qV8OcBq6Yfzd3bRED2D-8Y9Tbyo1S5LroikMNkzYBSn-JlJgjwfmdlHryPE4jTLW5gREE/s1600/14.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjBeGxa3eguHaT2QTyMpqsiQa25IVWSlr6LGaEFfOpQdaCQ2The_-_k5neLHXYK6EzyRldJ_qV8OcBq6Yfzd3bRED2D-8Y9Tbyo1S5LroikMNkzYBSn-JlJgjwfmdlHryPE4jTLW5gREE/s1600/14.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Database&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;h4 id=&quot;RES&quot; style=&quot;text-align: left;&quot;&gt;Restriction :&lt;/h4&gt;Embeddable classes, however, do not have an identity (primary key) of their own which leads to some limitations : &lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Embeddable instances cannot be shared by different entity objects﻿.&lt;/li&gt;
&lt;li&gt;Embeddable objects cannot be directly persisted, it can only be persisted or queried in the context of their parent.&lt;/li&gt;
&lt;li&gt;Embeddable objects does not have an id or table.&lt;/li&gt;
&lt;/ul&gt;So a decision whether to declare a class as an entity or embeddable requires case by case consideration.&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h4 id=&quot;SRC&quot; style=&quot;text-align: left;&quot;&gt;Download Source Code :&lt;/h4&gt;&lt;a href=&quot;https://github.com/jShiwaniGupta/JPA-Modeler-Example/tree/master/Embeddable%20Classes&quot;&gt;Github - Embeddable Classes&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jpamodeler.blogspot.com/feeds/7087172625220638694/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1110200500196347069/7087172625220638694' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1110200500196347069/posts/default/7087172625220638694'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1110200500196347069/posts/default/7087172625220638694'/><link rel='alternate' type='text/html' href='http://jpamodeler.blogspot.com/2015/11/embeddable.html' title='@Embeddable Classes in Action'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/16315177036314487677</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDxBLafSZDp3LwXHb9KXCOFaCKBw3hOCyFf4sL4i-wMS5nsOt5v85qAmiJTk9AW8H8ewZy0g5UWS2gfGfh_NUMYw0ytWNyj2zJ6QC8hxB5VejLwCQx4susUbqK-8onqPZNIWLr7OcDpS4/s72-c/ent.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1110200500196347069.post-5697624007717837073</id><published>2015-11-25T03:46:00.001-08:00</published><updated>2016-04-07T20:46:40.078-07:00</updated><title type='text'>@NamedStoredProcedureQuery in Action</title><content type='html'>&lt;br /&gt;
 &lt;script&gt;window.location.href=&quot;http://jpamodeler.github.io/tutorial/page.html?l=NamedStoredProcedureQuery&quot;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;  &lt;br /&gt;
&lt;h3 id=&quot;TOC&quot; style=&quot;text-align: left;&quot;&gt;Table of Content :&lt;/h3&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;#INT&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#DIA&quot;&gt;Create the JPA Diagram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#CSP&quot;&gt;Create the Stored Procedure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#GEC&quot;&gt;Generate the entity classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#ED&quot;&gt;Existing Database&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#TEST&quot;&gt;Create tester to call Named Stored Procedure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#DEPLOY&quot;&gt;Deploy the EJB Module&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#OUT&quot;&gt;Output&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#SRC&quot;&gt;Source Code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;h3 id=&quot;INT&quot; style=&quot;text-align: left;&quot;&gt;Introduction :&lt;/h3&gt;In this tutorial we will go through the basic execution of stored procedure using JPA Modeler .&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;JPA 2.1 supports : &lt;/span&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Named stored procedures calls defined in &lt;b&gt;@NamedStoredProcedureQuery&lt;/b&gt; annotation and created through &lt;b&gt;EntityManager.createNamedStoredProcedureQuery()&lt;/b&gt; .&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Dynamic stored procedure calls created through &lt;b&gt;EntityManager.createStoredProcedureQuery()&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;StoredProcedureQuery&lt;/b&gt; is a JPA Query that provides additional API for setting the stored procedure parameters, and for accessing output parameters and multiple result sets. A &lt;b&gt;StoredProcedureQuery&lt;/b&gt; can return entity objects, or data, similar to native SQL queries. A &lt;b&gt;ResultSetMapping&lt;/b&gt; can be used to map the returned fields to the entity columns. &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;h3 id=&quot;DIA&quot; style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Create the JPA Diagram :&lt;/span&gt;&lt;/h3&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Goto File menu &amp;gt; New File &amp;gt; Persistence category&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;From the Persistence , select &lt;b&gt;JPA Diagram from Database&lt;/b&gt; ( or create new JPA Diagram ) and click Next.&amp;nbsp;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJNXNwunGAphvjfUdxoHrBmOgGgtXN8CI-yTynW9r4HUAV434Xu9XU-iwSdGcnVSGewnrlYQijs-IfkUtZtmXXQWXHebhwPixGdHha9-BSlkI-xjOJ21Qqqs-CGtdkLUPHI_ArUZLHw1A/s1600/11.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJNXNwunGAphvjfUdxoHrBmOgGgtXN8CI-yTynW9r4HUAV434Xu9XU-iwSdGcnVSGewnrlYQijs-IfkUtZtmXXQWXHebhwPixGdHha9-BSlkI-xjOJ21Qqqs-CGtdkLUPHI_ArUZLHw1A/s1600/11.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Select JPA Diagram&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Select table and add to import entity from DB .&lt;/span&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVBuUeAscm17YPr9kvEB8MewshHNMTAmrqP77QYiZs5_y10ALZYQogrZ8VwdaA_Z_RKDhp77FtBcxrr0nWNG-bstlqtcx3_6DZBUzRug8VJL9QfqMEDxCiea_czUI6YCIpCezWc7cEdlw/s1600/2.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVBuUeAscm17YPr9kvEB8MewshHNMTAmrqP77QYiZs5_y10ALZYQogrZ8VwdaA_Z_RKDhp77FtBcxrr0nWNG-bstlqtcx3_6DZBUzRug8VJL9QfqMEDxCiea_czUI6YCIpCezWc7cEdlw/s1600/2.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Select Tables&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Type &lt;b&gt;SmapleERD&lt;/b&gt; for the diagram name.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Type &lt;b&gt;com.jpamodeler.nsp&lt;/b&gt; for the Package.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Click Finish.&lt;/span&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt_YAxEuh8KVHz-CF8dyJMP3nEODLebr9ni_GNEhCny5-I3pat6-F-iD-wF2TLuSPxupao530Pt8GATEmi-aVGEnGD3eronlG6jNuBXijC2ho-nF094V3hO4POYaioxEmz43EegWs_1h4/s1600/3.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt_YAxEuh8KVHz-CF8dyJMP3nEODLebr9ni_GNEhCny5-I3pat6-F-iD-wF2TLuSPxupao530Pt8GATEmi-aVGEnGD3eronlG6jNuBXijC2ho-nF094V3hO4POYaioxEmz43EegWs_1h4/s1600/3.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Create JPA Diagram&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;When we click Finish, the IDE creates the JPA Diagram and opens the diagram in the designer window.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3 id=&quot;CSP&quot; style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Create the Stored Procedure :&lt;/span&gt;&lt;/h3&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Click on the entity &amp;gt; Properties .&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;From the properties , select &lt;b&gt;Named Stored Procedure Query Property&lt;/b&gt;.&lt;/span&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgINUa3ttLAnSmq0wVvaLy1_uzLby1uj6YkQFyque65RM92wGiEdSFMX59A6RMbBmT3Dt5QDI4LyqfspzT9t3MgesmvNHTnWkBl-o9CvyGgac51HI9pKdAGv6zowo5gZwYiLhN_Fo_JAWU/s1600/4.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgINUa3ttLAnSmq0wVvaLy1_uzLby1uj6YkQFyque65RM92wGiEdSFMX59A6RMbBmT3Dt5QDI4LyqfspzT9t3MgesmvNHTnWkBl-o9CvyGgac51HI9pKdAGv6zowo5gZwYiLhN_Fo_JAWU/s1600/4.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Open Stored Procedure Query Panel&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Click on the Add button to create new named stored procedure .&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU4QV4QD1DN3EwAuy5e7nqU4M6Vi8c75RKla5oQLTHv7hRhRu5kaZEti5Dq3-L8R-R-VQQNIYntg7DQjavvq-4bryYuIeJYHKoZHVofmS8ikLLj1VH-FKATs6e4o5ogmbnv6G3gjdDbGg/s1600/5.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU4QV4QD1DN3EwAuy5e7nqU4M6Vi8c75RKla5oQLTHv7hRhRu5kaZEti5Dq3-L8R-R-VQQNIYntg7DQjavvq-4bryYuIeJYHKoZHVofmS8ikLLj1VH-FKATs6e4o5ogmbnv6G3gjdDbGg/s1600/5.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Create Stored Procedure&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;In this panel , first select the &lt;b&gt;Database connection&lt;/b&gt;.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;It will fetch the existing stored procedure list from the DB.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Now select the &lt;b&gt;Stored Procedure&lt;/b&gt; and it will fetch existing stored procedure parameter list from the DB.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT4cGrfSNwicq9x_GOZ_e2SuWuTRFIzwLz46XO76tE2EmDFuYbqbAKbdjzD7Vsw6M2Jim2AMzcBsj-qbmN2fwKBnpVH7ycWE4J5EDNfRLywiWXJ-wKSfVzWKFqxwDhrvKU4YxAAcotjVE/s1600/6.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT4cGrfSNwicq9x_GOZ_e2SuWuTRFIzwLz46XO76tE2EmDFuYbqbAKbdjzD7Vsw6M2Jim2AMzcBsj-qbmN2fwKBnpVH7ycWE4J5EDNfRLywiWXJ-wKSfVzWKFqxwDhrvKU4YxAAcotjVE/s1600/6.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Select Database Connection to fetch SP&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Click on the &lt;b&gt;Result Set&lt;/b&gt; Tab to add result classes or resultset mappings.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXeAHN2OO0hZNbRACMopq9K5AP-3oi5N_AnueGQEMwg48XnCB3FyMaho_q_4Em8-8uk0ZfRh1JSBVJjYKDHP54xvjmgyglq8tIyKBj-4GxM5pu-nAwScl_6v4zSm4yJTpEn_zaNdzygVI/s1600/7.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXeAHN2OO0hZNbRACMopq9K5AP-3oi5N_AnueGQEMwg48XnCB3FyMaho_q_4Em8-8uk0ZfRh1JSBVJjYKDHP54xvjmgyglq8tIyKBj-4GxM5pu-nAwScl_6v4zSm4yJTpEn_zaNdzygVI/s1600/7.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Select Result Classes&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Click on the save button to save named stored procedure.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh13ihcVmthOwCPk6UPHIlCk_3HvaYAlDRngjyU-Bqch2heYRnqlkwjORpe_hpDSi6xzqvGVX4FlewoO0j_edPTSIJldOvKG9BqARkgaEo2pZpTgULTaG4-KIB5gwiI-WpeWgSLlO-NrLA/s1600/8.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh13ihcVmthOwCPk6UPHIlCk_3HvaYAlDRngjyU-Bqch2heYRnqlkwjORpe_hpDSi6xzqvGVX4FlewoO0j_edPTSIJldOvKG9BqARkgaEo2pZpTgULTaG4-KIB5gwiI-WpeWgSLlO-NrLA/s1600/8.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Created Stored Procedure&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt; &lt;/span&gt; &lt;br /&gt;
&lt;div&gt;&lt;h3 id=&quot;GEC&quot; style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Generate the entity classes :&lt;/span&gt;&lt;/h3&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Right click on the diagram &amp;gt; Generate Source Code&lt;/span&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgosrSFX6jCm7TbsPq4PurQzWgCSzHdTUUi8v3T5Oylr0o3duoEblCwZWlTSQ8cO7vWSoY-nKgl1vTt8jKS4uDT2L-6GXVG_8pvnxO9u50RQLjC9MDAie6B6DTtYsuKZRVYM_FKlH3DM1o/s1600/9.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgosrSFX6jCm7TbsPq4PurQzWgCSzHdTUUi8v3T5Oylr0o3duoEblCwZWlTSQ8cO7vWSoY-nKgl1vTt8jKS4uDT2L-6GXVG_8pvnxO9u50RQLjC9MDAie6B6DTtYsuKZRVYM_FKlH3DM1o/s1600/9.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Generate Source Code&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Click on the Student entity class to view source code.&amp;nbsp;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;script src=&quot;https://gist.github.com/jShiwaniGupta/6f8e4e13de8ea736942e.js&quot;&gt;&lt;/script&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;h3 id=&quot;ED&quot; style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt; Existing Database :&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt; Click on the Services window &amp;gt; Databases&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFFF_wZQFwjbYkKsr63wr9RBMaFS6z4ZFgSplojvEeV1dYM2C144Il8pvGTjaJDc6VxxaeBWMRuLdcwEn9GLfziVyYWnQhHxdpWz-jkMCjmfGcdIcikJs2hdHaHnTkanjHV9BGliEb9cI/s1600/10.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFFF_wZQFwjbYkKsr63wr9RBMaFS6z4ZFgSplojvEeV1dYM2C144Il8pvGTjaJDc6VxxaeBWMRuLdcwEn9GLfziVyYWnQhHxdpWz-jkMCjmfGcdIcikJs2hdHaHnTkanjHV9BGliEb9cI/s1600/10.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Database existing table and data&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;I have used MySQL as backend database, however PostgreSQL , MS SQL Server or Oracle can also be used. As the schema I have used a simple table to store student’s data.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; Student Table SQL Query :&lt;/span&gt;&lt;/h4&gt;&lt;pre style=&quot;background: rgb(240, 240, 240); border-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.6px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;&quot;&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;student&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;SID&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot; style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;FNAME&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot; style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #40a070;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;LNAME&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot; style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #40a070;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;DEPT&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot; style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #40a070;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;BATCH&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot; style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;EMAIL&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot; style=&quot;color: #007020;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #40a070;&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;KEY&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;SID&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: 0.015em; line-height: 15.6px;&quot;&gt;));&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background: rgb(240, 240, 240); border-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.6px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;&quot;&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;INSERT&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;INTO&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sample_db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;student&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SID&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FNAME&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LNAME&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DEPT&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BATCH&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EMAIL&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;VALUES&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #40a070;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;Shiwani&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;Gupta&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;CSE&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;color: #40a070;&quot;&gt;2015&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;jShiwanGupta@gmail.com&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style=&quot;background: rgb(240, 240, 240); border-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.6px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;&quot;&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;INSERT&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;INTO&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sample_db&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;student&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SID&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FNAME&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LNAME&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DEPT&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BATCH&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EMAIL&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;VALUES&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #40a070;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;Gaurav&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;Gupta&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;IT&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;color: #40a070;&quot;&gt;2012&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;gaurav.gupta.jc@gmail.com&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/pre&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h4&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; Stored Procedure (MySQL) :&lt;/span&gt;&lt;/h4&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;pre style=&quot;background: rgb(240, 240, 240); border-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, monospace; font-size: 13px; font-weight: normal; letter-spacing: 0.015em; line-height: 15.6px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;&quot;&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;DELIMITER&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;@@&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;DROP&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;PROCEDURE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;studentAll&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;@@&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;PROCEDURE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sample_db&lt;/span&gt;&lt;span class=&quot;mf&quot; style=&quot;color: #40a070;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;studentAll&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
 &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;IN&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BATCH_NO&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;color: #007020;&quot;&gt;INT&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;BEGIN&lt;/span&gt;
  &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;STUDENT&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;WHERE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BATCH&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BATCH_NO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;END&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;@@&lt;/span&gt; 
&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;DELIMITER&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;/pre&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;h3 id=&quot;TEST&quot; style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt; Create tester to call Named Stored Procedure :&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;In this exercise we will create a simple startup singleton bean to esecute the store procedure and fetch the student by batch :&lt;/span&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Right-click the EJB module and choose File &amp;gt; New File wizard .&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;In the New File wizard, expand the Enterprises JavaBeans and select Session Beans as shown in the figure below.&lt;/span&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjF0SggPe70-uf94KypwhdnrUeLg5Yzr-fzZL21q6anpbWJ8tIjGd3WrGX3fROG7F-zXeIAOcVwV8GI2DrfJqcYMvTWM0Rscj3nOv-RJ3oH0XaHIPfnYdvJ-02P1P8wfR-ODmR4pvNj4z0/s1600/12.JPG&quot; style=&quot;font-family: inherit; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjF0SggPe70-uf94KypwhdnrUeLg5Yzr-fzZL21q6anpbWJ8tIjGd3WrGX3fROG7F-zXeIAOcVwV8GI2DrfJqcYMvTWM0Rscj3nOv-RJ3oH0XaHIPfnYdvJ-02P1P8wfR-ODmR4pvNj4z0/s1600/12.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 12.8px;&quot;&gt;&lt;span style=&quot;font-size: x-small; text-align: start;&quot;&gt;Create Tester&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;
&lt;li&gt;Now , we have to specify the EJB Name and the Package Location in the appropriate text fields and then click Finish.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;When we click Finish, the class &lt;b&gt;Tester.java&lt;/b&gt; opens in the Source Editor.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;script src=&quot;https://gist.github.com/jShiwaniGupta/0c625eab1edf2d9f1978.js&quot;&gt;&lt;/script&gt;  &lt;br /&gt;
&lt;h3 id=&quot;DEPLOY&quot; style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt; Deploy the EJB Module :&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;We can now build and deploy the EJB module. Right-click the &lt;b&gt;StoredProceduresModule&lt;/b&gt; module and choose Deploy. When we click Deploy, the IDE builds the ejb module and deploys the JAR archive to the server.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;In the Services window, if we expand the Applications node of GlassFish Server, we can see that &lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;StoredProceduresModule&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt; was deployed.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;After we have defined the &lt;b&gt;@NamedStoredProcedureQuery&lt;/b&gt;, we can use the &lt;b&gt;createNamedStoredProcedureQuery(String name)&lt;/b&gt; method of the &lt;b&gt;EntityManager&lt;/b&gt; to create a &lt;b&gt;StoredProcedureQuery&lt;/b&gt; object. This provides the required methods to set the input parameter, call the stored procedure and get the result.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3 id=&quot;OUT&quot; style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt; Output :&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;background: rgb(240, 240, 240); border-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.6px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;&quot;&gt;&lt;span class=&quot;na&quot; style=&quot;color: #4070a0;&quot;&gt;INFO&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;color: #4070a0;&quot;&gt;com.jpamodeler.nsp.Student actually got transformed &lt;/span&gt;
&lt;span class=&quot;na&quot; style=&quot;color: #4070a0;&quot;&gt;INFO&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;color: #4070a0;&quot;&gt;EclipseLink, version: Eclipse Persistence Services - 2.5.0.v20130507-3faac2b &lt;/span&gt;
&lt;span class=&quot;na&quot; style=&quot;color: #4070a0;&quot;&gt;INFO&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;color: #4070a0;&quot;&gt;file:/G:/jShiwaniGupta/NetBeans_Projects/StoredProceduresModule/build/classes/_DEFAULT_PU login successful &lt;/span&gt;
&lt;span class=&quot;na&quot; style=&quot;color: #4070a0;&quot;&gt;INFO&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;color: #4070a0;&quot;&gt;EJB5181:Portable JNDI names for EJB Tester: [java:global/StoredProceduresModule/Tester, java:global/StoredProceduresModule/Tester!com.jpamodeler.nsp.Tester] &lt;/span&gt;
&lt;b&gt;&lt;span class=&quot;na&quot; style=&quot;color: #4070a0;&quot;&gt;INFO&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;color: #4070a0;&quot;&gt;Executing Stored Procedure Query ................ &lt;/span&gt;
&lt;span class=&quot;na&quot; style=&quot;color: #4070a0;&quot;&gt;INFO&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;color: #4070a0;&quot;&gt;Student : Shiwani Gupta &lt;/span&gt;&lt;/b&gt;
&lt;span class=&quot;na&quot; style=&quot;color: #4070a0;&quot;&gt;INFO&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;color: #4070a0;&quot;&gt;StoredProceduresModule was successfully deployed in 1,185 milliseconds.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;h3 id=&quot;SRC&quot; style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Download Source Code :&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://github.com/jShiwaniGupta/JPA-Modeler-Example/tree/master/Named%20Stored%20Procedure&quot; target=&quot;_blank&quot;&gt;Github - Named Stored Procedure&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jpamodeler.blogspot.com/feeds/5697624007717837073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/1110200500196347069/5697624007717837073' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1110200500196347069/posts/default/5697624007717837073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1110200500196347069/posts/default/5697624007717837073'/><link rel='alternate' type='text/html' href='http://jpamodeler.blogspot.com/2015/11/namedstoredprocedurequery.html' title='@NamedStoredProcedureQuery in Action'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/16315177036314487677</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJNXNwunGAphvjfUdxoHrBmOgGgtXN8CI-yTynW9r4HUAV434Xu9XU-iwSdGcnVSGewnrlYQijs-IfkUtZtmXXQWXHebhwPixGdHha9-BSlkI-xjOJ21Qqqs-CGtdkLUPHI_ArUZLHw1A/s72-c/11.JPG" height="72" width="72"/><thr:total>1</thr:total></entry></feed>