<!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;">
    Re: how can I reverse engineer and create POJOs from an existing database?
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/johnqcitizen">John Citizen</a> in <i>JBoss Tools</i> - <a href="https://community.jboss.org/message/801478#801478">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>You don't have to use eclipse plugins here. You can also use the hibernate plugin for maven, and generate mapping files and POJOs from the command line.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You would define a pom.xml file as follows (I've left out some of the normal POMN stuff here) :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&lt;project&gt;</p><p>&#160; &lt;build&gt;</p><p>&#160;&#160;&#160; &lt;plugins&gt;</p><p>&#160;&#160;&#160;&#160; &lt;plugin&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;artifactId&gt;hibernate3-maven-plugin&lt;/artifactId&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;version&gt;2.2&lt;/version&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;configuration&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;components&gt;</p><p><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;component&gt;</span></p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;name&gt;hbm2hbmxml&lt;/name&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;implementation&gt;jdbcconfiguration&lt;/implementation&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;outputDirectory&gt;target/generated-resources/hibernate3&lt;/outputDirectory&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/component&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;component&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;name&gt;hbm2java&lt;/name&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;implementation&gt;jdbcconfiguration&lt;/implementation&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;outputDirectory&gt;target/generated-sources/hibernate3&lt;/outputDirectory&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/component&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/components&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;componentProperties&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;revengfile&gt;drc/main/resources/reveng.xml&lt;/revengfile&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;propertyfile&gt;src/main/resources/hibernate.properties&lt;/propertyfile&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;packagename&gt;com.whatever.domain&lt;/packagename&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;jdk5&gt;true&lt;/jdk5&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;ejb3&gt;true&lt;/ejb3&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/componentProperties&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/configuration&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;dependencies&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;dependency&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;groupId&gt;cglib&lt;/groupId&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;artifactId&gt;cglib-nodep&lt;/artifactId&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;version&gt;2.2.2&lt;/version&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/dependency&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;dependency&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;groupId&gt;com.oracle&lt;/groupId&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;artifactId&gt;ojdbc&lt;/artifactId&gt; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;version&gt;11.1.0.6.0&lt;/version&gt; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/dependency&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/dependencies&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;/plugin&gt;</p><p>&#160;&#160;&#160; &lt;/plugin&gt;</p><p>&#160; &lt;/build&gt;</p><p>&lt;/project&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You will need to change the values for the JDBC dependency (I'm using oracle).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You will also need to define a src/main/resources/hibernate.propeties file:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver</p><p>hibernate.connection.url=jdbc:oracle:thin:@&lt;server&gt;:&lt;port&gt;:&lt;instance&gt;</p><p>hibernate.connection.username=&lt;username&gt;</p><p>hibernate.connection.password=&lt;password&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>using suitable values for &lt;server&gt;, &lt;port&gt;, etc.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And a src/main/resources/reveng.xml file to define your reverse engineering strategy, e.g.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>?xml version="1.0" encoding="UTF-8"?&gt;</p><p>&lt;!DOCTYPE hibernate-reverse-engineering PUBLIC </p><p>&#160; "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" </p><p><span>&#160; "</span><a class="jive-link-external-small" href="http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" rel="nofollow" target="_blank">http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd</a><span>" &gt;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&lt;hibernate-reverse-engineering&gt;</p><p>&#160; <a class="jive-link-anchor-small" rel="nofollow">&lt;schema-selection match-schema="MY_SCHEMA"/&gt;</a></p><p><span style="font-size: 10pt;">&lt;/hibernate-reverse-engineering&gt;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This specifies that only tables in the MY_SCHEMA schema are used for generating POJOs.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Then run the following from the command line to generate POJOs with annotations:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>$ mvn hibernate3:hbm2java</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If you want to generate mapping files and POJOs without annotations, change the &lt;ejb3&gt; tag in the pom.xm to the following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160; &lt;ejb3&gt;false&lt;/ejb3&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>then run the following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160; $ mvn hibernate3:hbm2hbmxml</p><p>&#160;&#160; $ mvn hibernate3:hbm2java</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is just a taster. You will need to look up additional information to get this working.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Hope that helps.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/801478#801478">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Tools at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


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

</div>

</body>
</html>