How to create Data base reverse Engine


DB reverse engine:

1>First install Oracle or where you install oracle give the ptah name
2>Instal Eclipse Kepler
3>Go to Help--> About eclipse--->Jboss for Kepler
4>Install Jboss(10 minute min or max)
5>After Restart Eclipse
6>See in eclipse header one icon like Hibernate Code generation display
7>Create one project Give the name like HibernateReverse
8>Follow below Url:
  a>http://www.yuvalararat.com/2008/03/hibernate-auto-generate-hbm-and-java/

  or
Download the hibernate-tools jar. [i]
Extract the jar to plugins folder of Eclipse.
Start eclipse.
Click on [Right Click On Project ->File -> New -> Other -> Hibernate -> Hibernate Configuration File] and create a .cfg file. The following properties should be specified : jdbc url , username, password, DB schema, driver class and dialect.
Click on [Right Click On Project ->File -> New -> Other -> Hibernate ->  Hibernate Console Configuration ] and create a new console configuration. Add the jar file that contains your DB driver in the classpath section at the bottom.
Enter the name of the console configuration. Click Browse button against the Configuration file and select the cfg.xml file created in step 4.
Click on [File -> New -> Other -> Hibernate -> Hibernate Reverse Engineering File(reveng.xml) ] and select the location of the file.
Select the cfg.xml file created in step 4 as the Console Configuration. Click on include button and specift the schema and table name(s) to reverse engineer. Multiple table names can be specifed using sql wild char (eg: TBL_%). Click Finish.
Click on the Hibernate icon in the tool bar and select the [Hibernate Code Generation ..] option.
Right click on the [Hibernate Code Generation]tree node and select New.
Give the name of the configuration and select the console configuartion created in setp 5 and reveng.xml created in step6-7. Also select the Output Directory,
Go to the Exporters tab and check Generate domain code(.java) and Generate mappings (hbm.xml). Click run.
The hibernate mapping xml files and Java classes will be created in the output directory specified in step 11.



9>After that change hibernate.cfg.xml

  like bellow:
  
  <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
                        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory name="BUSINESSMASTER">
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.password">MCONNECTUIRND2</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@172.30.70.55:1521:testdb1</property>
        <property name="hibernate.connection.username">MCONNECTUIRND2</property>
        <property name="hibernate.default_schema">MCONNECTUIRND2</property>
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle9iDialect</property>
    </session-factory>
</hibernate-configuration>


10> Add external jar file in classpath
   1> activemq-all-5.6.0.jar
   2>c3p0-0.9.1-pre10.jar
   3>commons-dbcp-20030825.184428.jar
   4>commons-pool-20030825.183949.jar
   5>hibernate-commons-annotations-3.2.0.Final.jar
   6>hibernate-core-3.6.0.Final.jar
   7>hibernate-entitymanager-3.6.0.Final.jar
   8>hibernate-jpa-2.0-api-1.0.0.Final.jar
   9>jdom-1.0.jar
   10>jpos.jar
   11>log4j-1.2.14.jar
   13>mpos-core.jar
   14>mysql-connector-java-5.1.16.jar
   15>ojdbc14.jar
   16>spring-hibernate3-2.0-m4.jar
   17>spring-orm-3.0.5.RELEASE.jar
   18>spring-tx-3.0.0.RELEASE.jar
   19>velocity-1.6.2-dep.jar


11>See the details:



Previous
Next Post »