Header Ads Widget

Responsive Advertisement

How to create Data base reverse Engine


This guide details the steps to set up a Hibernate Reverse Engineering project with Oracle using Eclipse Kepler and Hibernate tools.

Step-by-Step Process for DB Reverse Engineering with Hibernate:


1. Install Oracle Database

Ø  Install Oracle Database or ensure it's already installed. Note the installation path for reference.


2. Install Eclipse Kepler

Ø  Download and install Eclipse Kepler from the Eclipse website.


3. Install JBoss Tools in Eclipse

Ø  In Eclipse, go to Help > Eclipse Marketplace.

Ø  Search for "JBoss Tools" and install it (JBoss Tools for Kepler).


4. Restart Eclipse

Ø  After JBoss Tools is installed, restart Eclipse.


5. Verify Hibernate Plugin Installation

Ø  Check for a Hibernate Code Generation icon in the Eclipse toolbar to confirm successful installation of Hibernate Tools.


6. Create a New Project for Reverse Engineering

Ø  In Eclipse, create a new project:

ü  Go to File > New > Project...

ü  Select Java Project and name it something like HibernateReverse.


7. Configure Hibernate in Eclipse

Follow the detailed guide from the URL: Hibernate Auto Generate HBM and Java.


8. Hibernate Tools Setup

Ø  Download Hibernate Tools from the official site or extract the Hibernate Tools jar into the plugins folder of Eclipse.


9. Configure Hibernate:

  1. Create Hibernate Configuration File (hibernate.cfg.xml):

ü  Right-click on the project > New > Other > Hibernate > Hibernate Configuration File.

ü  Provide the following details:

      • JDBC URL, Username, Password, DB Schema, Driver Class, and Dialect.
  1. Create Hibernate Console Configuration:

ü  Right-click the project > New > Other > Hibernate > Hibernate Console Configuration.

ü  Add the DB driver jar to the classpath.

ü  Set the cfg.xml file created in the previous step.

  1. Create Reverse Engineering File (reveng.xml):

ü  Right-click the project > New > Other > Hibernate > Hibernate Reverse Engineering File.

ü  Set the schema and table names using SQL wildcards (e.g., TBL_%) to reverse engineer multiple tables.

  1. Run Hibernate Code Generation:

ü  Click the Hibernate icon in the toolbar.

ü  Select Hibernate Code Generation, and create a new configuration with the reverse engineering file (reveng.xml).

ü  Go to the Exporters tab and check Generate domain code (.java) and Generate mappings (.hbm.xml).


10. Modify hibernate.cfg.xml

Here is an example configuration for Oracle:

xml

<?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:@1localhost: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>

 

Make sure to replace the username, password, DB schema, and JDBC URL with your own Oracle connection details.


11. Add Required External JAR Files to Classpath

Ø  Include the following jars in the classpath for your project:

    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
    12. mpos-core.jar
    13. mysql-connector-java-5.1.16.jar
    14. ojdbc14.jar (Oracle JDBC Driver)
    15. spring-hibernate3-2.0-m4.jar
    16. spring-orm-3.0.5.RELEASE.jar
    17. spring-tx-3.0.0.RELEASE.jar
    18. velocity-1.6.2-dep.jar

12. Generate Domain Classes and Hibernate Mappings

Ø  Run the Hibernate Code Generation tool, and it will create:

ü  Java classes (domain models).

ü  Hibernate mapping files (hbm.xml) for the tables in the reverse-engineered schema.


This process will automate the generation of Java domain classes and Hibernate mapping files from the Oracle database schema, saving development time when dealing with large databases.





Data base reverse Engine
Data base reverse Engine 

Post a Comment

0 Comments