<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    New Hibernate Tools features in JBDS 6
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="https://community.jboss.org/people/jpeterka">Jiri Peterka</a> in <i>JBoss Tools</i> - <a href="https://community.jboss.org/docs/DOC-48444">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><h1 dir="ltr"><span style="font-size: 24px; font-family: Arial; color: #000000;">New Hibernate tool features in JBDS 6</span></h1><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">This article will show you some of new features and enhancements in Hibernate Tools 3.6.0 which is part of JBoss Tools 4.0.0 and also JBoss Developer Studio 6.0.0 (further referred as JBDS).</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">We shall partially meet this areas of Hibernate tools in this tutorial:</span></p><ul><li><span style="font-size: 15px;">JBoss Hibernate tools libraries for code generation with ANT tasks support</span></li><li><span style="font-size: 15px;">New database profile connection features for Hibernate</span></li><li><span style="font-size: 15px;">Some new Hibernate features in JPA projects</span></li></ul><h2 dir="ltr"><span style="font-size: 19px; font-family: Arial; color: #000000;">Prerequisites</span></h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 16px; font-family: Arial; color: #666666; font-weight: bold;">JBoss Developer Studio</span></p><p><span style="font-size: 16px; font-family: Arial; color: #666666; font-weight: bold;"><br/></span></p><p><span style="font-size: 15px; font-family: Arial;">It&rsquo;s expected you have JDK 1.6 or higher and JBDS 6.0.0.GA that you can download from </span><a class="jive-link-external-small" href="https://devstudio.jboss.com/earlyaccess/6.0.0.GA.html" rel="nofollow"><span style="font-size: 15px; font-family: Arial; color: #1155cc;">https://devstudio.jboss.com/earlyaccess/6.0.0.GA.html</span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">and to install is simply using following command:</span></p><p><span style="font-size: 12px; font-family: 'Courier New'; background-color: #cccccc;">java -jar jbdevstudio-product-universal-6.0.0.GA-v20121206-1855-B186.jar</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Go through installer wizard and after it&rsquo;s finish start JBoss Developer Studio, select new workspace location and you should see a screen below .</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh6.googleusercontent.com/9y16idOz_-IPfChs59bIzoA8SrOy_yh55SwBWua0TLLhx68CxRE5t1kDfBETt1g1wcsMFtDqUX-WYTbThROCFk1-jXjecDLzWZ0wPN8dlUawjyeakdwOsXXpUQ"><span> https://lh6.googleusercontent.com/9y16idOz_-IPfChs59bIzoA8SrOy_yh55SwBWua0TLLhx68CxRE5t1kDfBETt1g1wcsMFtDqUX-WYTbThROCFk1-jXjecDLzWZ0wPN8dlUawjyeakdwOsXXpUQ </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Click on &ldquo;Get started with JBoss Central&#8221; and your IDE is ready for you.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3 dir="ltr"><span style="font-size: 16px; font-family: Arial; color: #666666;">Database</span></h3><p><span style="font-size: 15px; font-family: Arial;">Outside IDE download and start database needed for this tutorial. We will use sakila database running on h2 database. Follow these steps:</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 12px; font-family: 'Courier New'; background-color: #d9d9d9;">mkdir ~/db</span></p><p><span style="font-size: 12px; font-family: 'Courier New'; background-color: #d9d9d9;">cd db</span></p><p><span style="font-size: 12px; font-family: 'Courier New'; background-color: #d9d9d9;">git://github.com/maxandersen/sakila-h2.git</span></p><p><span style="font-size: 12px; font-family: 'Courier New'; background-color: #d9d9d9;">./sakila-h2/runh2.sh</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">You should see a database started</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh6.googleusercontent.com/Hw3EV7J7nHaciFPdfn7b5oudUpACIyARBAWbKG-fdSwK0mgnYMrDDfY6QUbAw4SvCsTlu9bWki2x-Z7VqZB4ke7uSiHNlNCcfngxd79oL35nFvsvYkz92zBybw"><span> https://lh6.googleusercontent.com/Hw3EV7J7nHaciFPdfn7b5oudUpACIyARBAWbKG-fdSwK0mgnYMrDDfY6QUbAw4SvCsTlu9bWki2x-Z7VqZB4ke7uSiHNlNCcfngxd79oL35nFvsvYkz92zBybw </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Go back to IDE and check the database. Switch to &ldquo;Database Development&#8221; perspective. And define database connection. In &ldquo;Data Source Explorer&#8221; view define new connection by context menu. Select Generic JDBC Driver (because there is not specific profile for h2)</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh6.googleusercontent.com/y0iWJEdGmdLO1aH2mNer-Ck9v7lJhlun2F5ppLo38Kdad_Bz7QOu7c064zfUlSkDBTlc-ql7LnVuoyvSdSNikEXJeIBrnwXK-S1Ulf3HKAHZkSBEo3KDOH1YnA"><span> https://lh6.googleusercontent.com/y0iWJEdGmdLO1aH2mNer-Ck9v7lJhlun2F5ppLo38Kdad_Bz7QOu7c064zfUlSkDBTlc-ql7LnVuoyvSdSNikEXJeIBrnwXK-S1Ulf3HKAHZkSBEo3KDOH1YnA </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Switch&#160; to &ldquo;JAR List&#8221; tab and add h2-&lt;version&gt;.jar from h2 where you have installed it. Then go to properties and add jdbc connection as written by started sakila db server. Update drive class (you can use auto lookup feature if you want).</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh3.googleusercontent.com/p_jkbXQmCQpEu0sAHAhulV8IhTb91yxwx4syl0C6nTvAL7gpXM7PMNO6pnMbQd5gXDcjsbAHCjLOlB32VO5c1LeHY2pd0Zs5FBJy8BPQNNMZ7Es4l0dChnMrxw"><span> https://lh3.googleusercontent.com/p_jkbXQmCQpEu0sAHAhulV8IhTb91yxwx4syl0C6nTvAL7gpXM7PMNO6pnMbQd5gXDcjsbAHCjLOlB32VO5c1LeHY2pd0Zs5FBJy8BPQNNMZ7Es4l0dChnMrxw </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Now you can test connection by clicking &ldquo;Test Connection button&#8221;</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh5.googleusercontent.com/j9pr-eVRTqrhDCfbgSuYK0PX99iPGtbiI6QJABum5HWA_0Qt0Yy-pZGPqNicMP1f0k2Os8GGi34hnL8DCSP3ePcDqldT9uRHGlulp30kOsjQG-awSgs7VmDYVg"><span> https://lh5.googleusercontent.com/j9pr-eVRTqrhDCfbgSuYK0PX99iPGtbiI6QJABum5HWA_0Qt0Yy-pZGPqNicMP1f0k2Os8GGi34hnL8DCSP3ePcDqldT9uRHGlulp30kOsjQG-awSgs7VmDYVg </span></a></p><h2 dir="ltr"><span style="font-size: 15px; font-family: Arial; color: #000000; font-weight: normal;">You should see &ldquo;Ping succeeded!&#8221; message box. After it&rsquo;s closing, just just click Finish.</span></h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Now you can browse database structure and can see database content if you want. </span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh4.googleusercontent.com/nt4e84GBv2OO4XuSUgOEsvHz3NWuFxX-JwxMe0nGWYmAjP5_-fNgSO4mNOPgEj_4urDTmu9cQADA1yzSeHjiPO_JC6dF25a1IH8EVI098NiVC4YiDvT_ocsPHQ"><span> https://lh4.googleusercontent.com/nt4e84GBv2OO4XuSUgOEsvHz3NWuFxX-JwxMe0nGWYmAjP5_-fNgSO4mNOPgEj_4urDTmu9cQADA1yzSeHjiPO_JC6dF25a1IH8EVI098NiVC4YiDvT_ocsPHQ </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Well, prerequisites are over so let&rsquo;s take a look what hibernate tools provides. </span></p><h2 dir="ltr"><span style="font-size: 19px; font-family: Arial; color: #000000;">NEW FEATURE: Hibernate tools libraries update</span></h2><p><span style="font-size: 15px; font-family: Arial;">One thing that was updated in JBDS 6 is Hibernate Tools for Ant. It was updated to these versions.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ul><li><span style="font-size: 15px;">3.4.0.CR2 for Hibernate 3.5</span></li><li><span style="font-size: 15px;">3.6.0.CR1 for Hibernate 3.6</span></li><li><span style="font-size: 15px;">4.0.0.CR1 for Hibernate 4</span></li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">So let&rsquo;s refresh our memory and try small tutorial how to use this feature in JBDS. We will create simple plug-in project and let UI to generate java db entities and also build.xml using hibernate-tools.jar ant tasks that can be modified and used further. Then we shall import ant file into our project, slightly update it and and execute it. </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Now create a testing project. In menu navigate: </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">New -&gt; Other &#8230; -&gt; Plug-in project</span></p><p><span style="font-size: 15px; font-family: Arial; font-style: italic;"><br/></span></p><p><a href="https://lh3.googleusercontent.com/snmZAUub5K6UFo5sKKBldEbTNCZOvqUtNeVH6po135g6-D0irnP0Cb4hEXcqzGnOolFYBOvf6IxsfGx2FcUFO581sMwMCRYG0TDr9NkIa54Lmo8XxxvbD9vHpw"><span> https://lh3.googleusercontent.com/snmZAUub5K6UFo5sKKBldEbTNCZOvqUtNeVH6po135g6-D0irnP0Cb4hEXcqzGnOolFYBOvf6IxsfGx2FcUFO581sMwMCRYG0TDr9NkIa54Lmo8XxxvbD9vHpw </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">In wizard navigate: </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">Next</span></p><p><span style="font-size: 15px; font-family: Arial; font-style: italic;"><br/></span></p><p><a href="https://lh4.googleusercontent.com/m5EPpl2Bydw7QPb7XO6qJbGzREDt8ZSquDTu4zy97sUEX07eZmq4GClAPPovdnxvNeHwXhd-LLQLdT8yqXqHVCWuPT501BQm590DNB_0_PaeJGs0fNXIbWAZNQ"><span> https://lh4.googleusercontent.com/m5EPpl2Bydw7QPb7XO6qJbGzREDt8ZSquDTu4zy97sUEX07eZmq4GClAPPovdnxvNeHwXhd-LLQLdT8yqXqHVCWuPT501BQm590DNB_0_PaeJGs0fNXIbWAZNQ </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">In wizard navigate: </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">Next, Finish</span><span style="font-size: 15px; font-family: Arial;">. </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Nice, your project is created. You can also create Java Project or any other type either&#160; mavenized or Eclipse type project. </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Additional steps would be only slightly different. We created eclipse plug-in project so we can easily add dependencies via manifest file. </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Now open MANIFEST.MF in Package Explorer to add hibernate-tools into our project. </span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh5.googleusercontent.com/DedhkVJeb-F7sScMpctDwVx_i-Re3bSnWyX2Sw-7gTd_MjBDqE-JZjyGULSiEPn8gaRvAqr4GJkPjUEK2cUIc6am0BD8TmSNs8qieiixx-AtWhGYbME0ePq6Hg"><span> https://lh5.googleusercontent.com/DedhkVJeb-F7sScMpctDwVx_i-Re3bSnWyX2Sw-7gTd_MjBDqE-JZjyGULSiEPn8gaRvAqr4GJkPjUEK2cUIc6am0BD8TmSNs8qieiixx-AtWhGYbME0ePq6Hg </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Switch to &ldquo;Dependencies&#8221; tab click &ldquo;Add...&#8221; button and start type &ldquo;org.jboss.tools.hibernate&#8221; and select &ldquo;org.jboss.tools.hibernate4_0&#8221; which adds hibernate libraries to our project (and mainly desired hibernate-tools.jar for Hibernate 4.0. </span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh6.googleusercontent.com/s6HcHQIgo5NxeO2dBNPk-qyARc1jBpCB28m83Zwpq03RA0bAzNwgfQuO7FLCc-8rNOrbA7s15u6uQV9PovRwnMP8ZqbsLyde39kSUB7IdCqAdE9Ek6NTDy_5Vg"><span> https://lh6.googleusercontent.com/s6HcHQIgo5NxeO2dBNPk-qyARc1jBpCB28m83Zwpq03RA0bAzNwgfQuO7FLCc-8rNOrbA7s15u6uQV9PovRwnMP8ZqbsLyde39kSUB7IdCqAdE9Ek6NTDy_5Vg </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">When hibernate plugin is added into your </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">MANIFEST.MF</span><span style="font-size: 15px; font-family: Arial;">, you can save and close the editor. </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">L</span><span style="font-family: Arial; font-size: 15px;">et&rsquo;s create hibernate configuration.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">In menu navigate to: </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">New -&gt; Other &#8230; -&gt; Hibernate Configuration File (cfg.xml). </span><span style="font-size: 15px; font-family: Arial;">Click </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">Next, </span><span style="font-size: 15px; font-family: Arial;">select src folder and click </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">Next</span></p><p><span style="font-size: 15px; font-family: Arial; font-style: italic;"><br/></span></p><p><a href="https://lh4.googleusercontent.com/WxC_TtmF3jLxsPAt2MxzF5JL6vxTCdohCS_GgSW7uAEidlkBAXvbbMRZMaP-8YSzaw24osKaWGVBssnW6a6n3AqmiwpJg6o7xIUz0fyGO_GYChFYm6fHDf3clA"><span> https://lh4.googleusercontent.com/WxC_TtmF3jLxsPAt2MxzF5JL6vxTCdohCS_GgSW7uAEidlkBAXvbbMRZMaP-8YSzaw24osKaWGVBssnW6a6n3AqmiwpJg6o7xIUz0fyGO_GYChFYm6fHDf3clA </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 19px; font-family: Arial; font-weight: bold;">NEW FEATURE: Connection profile can be used for hibernate configuration settings</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">One of new features is &ldquo;</span><span style="font-size: 15px; font-family: Arial; font-style: italic;">Get values from connection</span><span style="font-size: 15px; font-family: Arial;">&#8221;. Since we&rsquo;ve already created database connection profile we can use it. </span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh6.googleusercontent.com/RNn0jiRNmWcDgDug1aJmNbMfR03MROV0Gzqe4tM9b-cUk0cOIQJ-NWcWi4U_n69JZ0KNCPtlk7DX_LbbYN4faQ0nVjbGvvXcGhxc82GLP5H3ljBFd17ozLsNRQ"><span> https://lh6.googleusercontent.com/RNn0jiRNmWcDgDug1aJmNbMfR03MROV0Gzqe4tM9b-cUk0cOIQJ-NWcWi4U_n69JZ0KNCPtlk7DX_LbbYN4faQ0nVjbGvvXcGhxc82GLP5H3ljBFd17ozLsNRQ </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="https://lh3.googleusercontent.com/ksHlLJumN5CF5oDxoRiwrjndxkG-vRqMwktc-do_8tV45TPnAB-yvX2U_DQXgaYZXD_IPPl5lOKyOQ4nXb7hoK6emw18yIzw2kl6i-6jBrOD9GlfylMGG9n-ew"><span> https://lh3.googleusercontent.com/ksHlLJumN5CF5oDxoRiwrjndxkG-vRqMwktc-do_8tV45TPnAB-yvX2U_DQXgaYZXD_IPPl5lOKyOQ4nXb7hoK6emw18yIzw2kl6i-6jBrOD9GlfylMGG9n-ew </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">You can see the values were filled. We just need to add some additional properties like database dialect, etc. Check &ldquo;Create a console configuration&#8221; and &ldquo;Next&#8221;. Here just switch &ldquo;</span><span style="font-size: 15px; font-family: Arial; font-style: italic;">Hibernate Version</span><span style="font-size: 15px; font-family: Arial;">&#8221; to &ldquo;4.0&#8221;. Click Finish.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 19px; font-family: Arial; font-weight: bold;">NEW FEATURE: Connection profile can be used for datasource connection settings</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">It&rsquo;s not part of this tutorial but similarly we can use this feature also while creating datasource file for application server like JBoss AS os EAP. To use it navigate to </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">New -&gt; Other... -&gt; JBoss Datasource (-ds.xml).</span></p><p><span style="font-size: 15px; font-family: Arial; font-style: italic;"><br/></span></p><p><a href="https://lh5.googleusercontent.com/o-3fjbCN1Ah-aArR9uS8tJ60p3Cvj-SvNgHNWboSektTT8UY3Kj2OL2DYKJQ9IpXJpGcZ96SeFSoq1tuxD3WJGdJ9h1GpK18yKBQyuVyxrpNSnl5SvnKZYYZ4w"><span> https://lh5.googleusercontent.com/o-3fjbCN1Ah-aArR9uS8tJ60p3Cvj-SvNgHNWboSektTT8UY3Kj2OL2DYKJQ9IpXJpGcZ96SeFSoq1tuxD3WJGdJ9h1GpK18yKBQyuVyxrpNSnl5SvnKZYYZ4w </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Ok, let&rsquo;s continue with our example. Let&rsquo;s try to generate some code from our database. Switch to &ldquo;Hibernate&#8221; perspective if you already didn&rsquo;t do that. Now navigate to </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">Run -&gt; Hibernate Code Generation -&gt; Hibernate Code Generation Configurations...&#160; </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">You should see dialog similar to one below. Your configuration is already there so we can configure it a little bit and generate some code. Select your &ldquo;Console configuration&#8221;, check &ldquo;Reverse engineer from JDBC Connection&#8221; and add some package for exported entities.&#160; Select also your project src as &ldquo;Output directory:&#8221;.</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh3.googleusercontent.com/GCJcd_4n74WmPl4Z4dPEGtn5MlpQpKspmM4tjwELeFF8WQcygrw9A1pVcnrbvJ2Q9oWs9L_skyoPxInrYogPTeqsk1uEm3gHhOvbDWJ3rKrLDlSgcoh3pVzmHA"><span> https://lh3.googleusercontent.com/GCJcd_4n74WmPl4Z4dPEGtn5MlpQpKspmM4tjwELeFF8WQcygrw9A1pVcnrbvJ2Q9oWs9L_skyoPxInrYogPTeqsk1uEm3gHhOvbDWJ3rKrLDlSgcoh3pVzmHA </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">On &ldquo;Exporters&#8221;&#160; tab you can select Domain code or any other artefacts you want to generate (note that some of them requires additional configuration). </span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh4.googleusercontent.com/jMT2x8GNex6g5wrF_y2SWAdLN-hY2lBBxNLvN71e5CmHnLxz-Q5bwB8B3XDdZVriyKP9yC6MODvuuePZCMjmd4oa3qj0XreMTtETt0LB0LSzM7IGkxDONuuYcQ"><span> https://lh4.googleusercontent.com/jMT2x8GNex6g5wrF_y2SWAdLN-hY2lBBxNLvN71e5CmHnLxz-Q5bwB8B3XDdZVriyKP9yC6MODvuuePZCMjmd4oa3qj0XreMTtETt0LB0LSzM7IGkxDONuuYcQ </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">When you click &ldquo;Run&#8221; your code will be generated. There are many other possibilities how to tweak your exports (like reveng files, etc.) but it&rsquo;s beyond this tutorial.&#160; Anyway you have exported entities.</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh6.googleusercontent.com/Y95LxhoU9diaA9XE-sKBU1bKbk90hEW6YvNcxYoPxChd1XVY3Rt81rq3s7dOdA6MCl8YKlm_RZ-FfRMXZm_ly7Ssfx6wzL3E8de51z1xfTsWuXH5BXjH3IJ_ZA"><span> https://lh6.googleusercontent.com/Y95LxhoU9diaA9XE-sKBU1bKbk90hEW6YvNcxYoPxChd1XVY3Rt81rq3s7dOdA6MCl8YKlm_RZ-FfRMXZm_ly7Ssfx6wzL3E8de51z1xfTsWuXH5BXjH3IJ_ZA </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">During code generation there was some &ldquo;magic&#8221; done. Let&rsquo;s see what happened. This export we&rsquo;ve just made is done by hibernate-tools.jar ant task which is used in generated build.xml. Let&rsquo;s see if we can take a look at this ant file.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">So now try get the ant file. Click On project, invoke context menu and select </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">&ldquo;Export&#8221; -&gt; &ldquo;Hibernate&#8221; -&gt; &ldquo;Ant Code Generation&#8221;</span></p><p><span style="font-size: 15px; font-family: Arial; font-style: italic;"><br/></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="https://lh5.googleusercontent.com/qQqPmOZuV3621uS-d7MwlRZ8LIeg3wbr0dJswlWlkpmPT2NKW4bC-KoaXOzDqS7M2Ky_bnTF_CMis3C3fBWZx_-3_UaD80HgWL6dfD2MjhAfew76iHHMeq3suA"><span> https://lh5.googleusercontent.com/qQqPmOZuV3621uS-d7MwlRZ8LIeg3wbr0dJswlWlkpmPT2NKW4bC-KoaXOzDqS7M2Ky_bnTF_CMis3C3fBWZx_-3_UaD80HgWL6dfD2MjhAfew76iHHMeq3suA </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Select Hibernate configuration, select project, fill in the &ldquo;File name:&#8221; to export and click Finish. </span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh6.googleusercontent.com/9fL3xfB_ty3SYcjXvEce6A_fMT98k1QM1vqO6EN6Ye5uZBkPBeRyZmju3mJLPWl7hf9aJHx33obEYr-_XVz3kWdjeURKzbGHjMKT4O1Iuw4prtZ_lfBGlbZ3sw"><span> https://lh6.googleusercontent.com/9fL3xfB_ty3SYcjXvEce6A_fMT98k1QM1vqO6EN6Ye5uZBkPBeRyZmju3mJLPWl7hf9aJHx33obEYr-_XVz3kWdjeURKzbGHjMKT4O1Iuw4prtZ_lfBGlbZ3sw </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">We we successful, build.xml is available in our plug-in project. We can see HibernateToolTask target which is executes &lt;hbm2java&gt; task.</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh6.googleusercontent.com/V7uIDxTPmX2zDNRmMZttwn3rU9IvglZOXh1R1czy7cwkmBIUG_sS66-EyiNRSRFaGk5mxVXfDiOT64-PzoYCCbOzJ8KFSBkzfF_DPFF_o20oktcLKxR2XZRetA"><span> https://lh6.googleusercontent.com/V7uIDxTPmX2zDNRmMZttwn3rU9IvglZOXh1R1czy7cwkmBIUG_sS66-EyiNRSRFaGk5mxVXfDiOT64-PzoYCCbOzJ8KFSBkzfF_DPFF_o20oktcLKxR2XZRetA </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">You can now use and customize ant xml file to achieve your specific goals by adding and modifying ant tasks and of course you can use code completion. Not that you can use it for generating different types of hibernate configuration, for various export types and definition and more.&#160; And of course this script works also outside an IDE. For more details see a </span><a class="jive-link-external-small" href="https://access.redhat.com/knowledge/docs/en-US/JBoss_Developer_Studio/6.0/html/Hibernate_Tools_Reference_Guide/ant.html" rel="nofollow"><span style="font-size: 15px; font-family: Arial; color: #1155cc;">documentation</span></a><span style="font-size: 15px; font-family: Arial;">.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Not let&rsquo;s take a shortly look on some other features that are available. </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 19px; font-family: Arial; font-weight: bold;">NEW FEATURE: Persistence.xml is update with connection profile information automatically</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">As the title refers you don&rsquo;t have to add connection informations into persistence.xml manually.&#160; You can see it for yourself. Just </span><span style="font-size: 15px; font-family: Arial;">Create &ldquo;New JPA Project&#8221; (again </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">New -&gt; Others... -&gt; JPA Project</span><span style="font-size: 15px; font-family: Arial;">)</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh5.googleusercontent.com/gKgJ8AmiGcaAv3yX-ZQ_Zyufr8DvhabPdbRNzckbXNZapuUausXIK6MTcBFzN7S62v8uig9b9LvtUgkAGtH3fMLKpECfNdMEO9ks6qA0IY9QM5AkrRNW6rKf0A"><span> https://lh5.googleusercontent.com/gKgJ8AmiGcaAv3yX-ZQ_Zyufr8DvhabPdbRNzckbXNZapuUausXIK6MTcBFzN7S62v8uig9b9LvtUgkAGtH3fMLKpECfNdMEO9ks6qA0IY9QM5AkrRNW6rKf0A </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Fill in basic properties like &ldquo;</span><span style="font-size: 15px; font-family: Arial; font-style: italic;">Project name</span><span style="font-size: 15px; font-family: Arial;">&#8221;.</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh5.googleusercontent.com/xK5tluIA9T-VPOpEpyHGnkZDA82C6i1mArLOddDdbHqZ3njrSPt65qhmtuDzznOZArrkYvqyFeaSaAT5ntRiNOu8X7WMVSEgb0OPnwcRT9zW7KmDpR1e_JK0Pw"><span> https://lh5.googleusercontent.com/xK5tluIA9T-VPOpEpyHGnkZDA82C6i1mArLOddDdbHqZ3njrSPt65qhmtuDzznOZArrkYvqyFeaSaAT5ntRiNOu8X7WMVSEgb0OPnwcRT9zW7KmDpR1e_JK0Pw </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Select &ldquo;Hibernate (JPA 2.x)&#8221; platform and set connection to a connection you&rsquo;ve created before.</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh4.googleusercontent.com/9eCBDt0Fw-2AFLS3Bbs_Beg12QA9iSpKzGWsGOqWYXPBIxeQB5xMa_acL0QxR2PzlnA6iBHz7wyDmjSXlaifjuwjGqbOsHixXGfIdVPGV4rRso9YNWxhfthR7A"><span> https://lh4.googleusercontent.com/9eCBDt0Fw-2AFLS3Bbs_Beg12QA9iSpKzGWsGOqWYXPBIxeQB5xMa_acL0QxR2PzlnA6iBHz7wyDmjSXlaifjuwjGqbOsHixXGfIdVPGV4rRso9YNWxhfthR7A </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">And click Finish. When you open persistence.xml, you can see your connection is properly configured.</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh3.googleusercontent.com/ta--ERrdFssKUolw7aCOOVw7AbIi9Pe6MoBKK6CyGwIgEWKPsQgeyND8jSsqxdDl4ilp_p068qDSsAWvCWLx4DuhMUjQiF_kFn5w1xyiMWQ3blZprS6-LZJ3cQ"><span> https://lh3.googleusercontent.com/ta--ERrdFssKUolw7aCOOVw7AbIi9Pe6MoBKK6CyGwIgEWKPsQgeyND8jSsqxdDl4ilp_p068qDSsAWvCWLx4DuhMUjQiF_kFn5w1xyiMWQ3blZprS6-LZJ3cQ </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Let&rsquo;s see another features. We will use a project created before. </span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 19px; font-family: Arial; font-weight: bold;">NEW FEATURE: Persistence.xml is update with connection profile information automatically</span></p><p><span style="font-size: 19px; font-family: Arial; font-weight: bold;"><br/></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Before continuing add Hibernate libraries to JPA Project (you can use libraries available in JBDS in from plugins/org.jboss.tools.hibernate4_.... /lib/required). Without this feature will not work.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">Select JPA project and from context menu use &ldquo;</span><span style="font-size: 15px; font-family: Arial; font-style: italic;">JPA Tools -&gt; Generate Entities from tables</span><span style="font-size: 15px; font-family: Arial;">&#8221;. Set basic parameters like what package should be used for entities generation and correct hibernate configuration. Click </span><span style="font-size: 15px; font-family: Arial; font-style: italic;">Finish</span><span style="font-size: 15px; font-family: Arial;">.</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh5.googleusercontent.com/WHmxN1LGfxnpO92hUrvW91jINMemiCEG-nGTFUnbOzXKf6PsjclS_heW94PDPk6S5e3DzzuNVYBZoF4zcjmPYltNqevVGah8BVmkR-VfHfSXAm_GMyxB9KXLOw"><span> https://lh5.googleusercontent.com/WHmxN1LGfxnpO92hUrvW91jINMemiCEG-nGTFUnbOzXKf6PsjclS_heW94PDPk6S5e3DzzuNVYBZoF4zcjmPYltNqevVGah8BVmkR-VfHfSXAm_GMyxB9KXLOw </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">When you check persistence.xml, JBDS updated your persistence.xml accordingly with new entities. If your persistence.xml is opened during code generation you can see it live.</span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p><a href="https://lh3.googleusercontent.com/7wBWkVsEXVEeaWabGjIe7bLCNu88X2XDTm2avehwk3NCcQZpe5Fu9rGSIXK2ZyzdYdOZtXjVXQRuyXsGJUpan33Q99bky3iUyPEbiVXuetuqaCVceY2Tuvovqw"><span> https://lh3.googleusercontent.com/7wBWkVsEXVEeaWabGjIe7bLCNu88X2XDTm2avehwk3NCcQZpe5Fu9rGSIXK2ZyzdYdOZtXjVXQRuyXsGJUpan33Q99bky3iUyPEbiVXuetuqaCVceY2Tuvovqw </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">There are many others Hibernate features available in latest stable Hibernate Tools that is available within JBoss Tools or JBoss Developer Studio. You can see all Hibernate tools features for JBDS 6.0.0 </span><a class="jive-link-external-small" href="https://issues.jboss.org/issues/?filter=12318813"><span style="font-size: 15px; font-family: Arial; color: #1155cc;">here</span></a><span style="font-size: 15px; font-family: Arial;">. </span></p><p><span style="font-size: 15px; font-family: Arial;"><br/></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 15px; font-family: Arial;">That&rsquo;s all, enjoy latest Hibernate Tools! If you have any comment please share it below.</span></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="https://community.jboss.org/docs/DOC-48444">going to Community</a></p>

        <p style="margin: 0;">Create a new document in JBoss Tools at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2128">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>