<!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;"> </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;"> </p><p><project></p><p>  <build></p><p>    <plugins></p><p>     <plugin></p><p>       <groupId>org.codehaus.mojo</groupId></p><p>       <artifactId>hibernate3-maven-plugin</artifactId></p><p>       <version>2.2</version></p><p>         <configuration></p><p>           <components></p><p><span style="font-size: 10pt;">             <component></span></p><p>               <name>hbm2hbmxml</name></p><p>               <implementation>jdbcconfiguration</implementation></p><p>               <outputDirectory>target/generated-resources/hibernate3</outputDirectory></p><p>             </component></p><p>             <component></p><p>               <name>hbm2java</name></p><p>               <implementation>jdbcconfiguration</implementation></p><p>               <outputDirectory>target/generated-sources/hibernate3</outputDirectory></p><p>             </component></p><p>           </components></p><p>           <componentProperties></p><p>             <revengfile>drc/main/resources/reveng.xml</revengfile></p><p>             <propertyfile>src/main/resources/hibernate.properties</propertyfile></p><p>             <packagename>com.whatever.domain</packagename></p><p>             <jdk5>true</jdk5></p><p>             <ejb3>true</ejb3></p><p>           </componentProperties></p><p>         </configuration></p><p>         <dependencies></p><p>           <dependency></p><p>             <groupId>cglib</groupId></p><p>             <artifactId>cglib-nodep</artifactId></p><p>             <version>2.2.2</version></p><p>           </dependency></p><p>           <dependency></p><p>             <groupId>com.oracle</groupId></p><p>             <artifactId>ojdbc</artifactId> </p><p>             <version>11.1.0.6.0</version> </p><p>           </dependency></p><p>         </dependencies></p><p>       </plugin></p><p>    </plugin></p><p>  </build></p><p></project></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </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;"> </p><p>hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver</p><p>hibernate.connection.url=jdbc:oracle:thin:@<server>:<port>:<instance></p><p>hibernate.connection.username=<username></p><p>hibernate.connection.password=<password></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>using suitable values for <server>, <port>, etc.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </p><p>?xml version="1.0" encoding="UTF-8"?></p><p><!DOCTYPE hibernate-reverse-engineering PUBLIC </p><p>  "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" </p><p><span>  "</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>" ></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><hibernate-reverse-engineering></p><p>  <a class="jive-link-anchor-small" rel="nofollow"><schema-selection match-schema="MY_SCHEMA"/></a></p><p><span style="font-size: 10pt;"></hibernate-reverse-engineering></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </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;"> </p><p>$ mvn hibernate3:hbm2java</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>If you want to generate mapping files and POJOs without annotations, change the <ejb3> tag in the pom.xm to the following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <ejb3>false</ejb3></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>then run the following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  $ mvn hibernate3:hbm2hbmxml</p><p>   $ mvn hibernate3:hbm2java</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </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>