Generate Hibernate map with Oracle database

Hibernate is a popular and high performance object/relational persistence Java development framework. DB-VA provides comprehensive development environment for Java developers to design and generate persistence layer. This tutorial shows you how to transform database design, which is the ERD, to class diagram, and eventually generate source files and Hibernate mapping layer from it.
Topics
1. Drawing ERD
2. Generating UML class diagram
3. Generate DAO Java source and Hibernate mapping XML

September 1, 2009
User Rating: / 3
Views: 6,486
PDF Link Add comments

The database design for the Computer Sales project:

Computer Sales project ERD

  1. In order to generate the Hibernate mapping, you need to synchronize the ERD and class diagram first. Right click on the ERD and select Synchronize to Class Diagram.
    Synchronize ERD to Class Diagram
  2. The Select diagram for synchronize dialog box appear. Select Create new diagram, input Persistent Class Diagram as the diagram name and click Create.
    Synchronize ERD to Persistent Class Diagram
  3. The Synchronize to Class Diagram dialog box appear. You may customize the synchronized class/attribute name. Click OK to continue.
    Preview synchronize from ERD to class diagram
  4. The class diagram is produced.
    Synchronized to class diagram
  5. Specify com.computersales as the package header.
    Change package header of persistent class diagram
  6. To generate hibernate mapping, select Tools > Object-Relational Mapping (ORM) > Generate Code... from the main menu.
    Generate code in ORM
  7. In the Database Code Generation dialog box, select Code and Database as the generation type.
    Select to generate code and database
  8. Specify the output path of source files, Hibernate mapping files, DDL and library files.
    Specify output path
  9. Select DAO as the Persistent API.
    Specify persistent API
  10. Make sure the Export to database option in the Database tab is unchecked.
    Avoid export to database directly
  11. Press OK to start the generation.
    <span class='notranslate'>Java</span> code and database is generated
  12. Let's take a look at the generated files.
    Browse generated files
  13. The source files are placed at ${outputPath}\src.
    File list of generated code
  14. Let's open the generated source file.
    Generated java code from ORM
  15. The Hibernate mapping files are placed at ${outputPath}\src\ormmapping.
    File list of generated <span class='notranslate'>Hibernate</span> map
  16. Let's open the generated Hibernate mapping file.
    Generated <span class='notranslate'>Hibernate</span> map file

Download full functions 30 days FREE trial of DB Visual ARCHITECT

Windows
Linux
Mac OSX

Notes:
1. Select DB Visual ARCHITECT when installing the VP Suite.
2. Click "Try without Evaluation Key" button to get 30 minutes per session evaluation.
3. Click "Request Key" to get a 30-day evaluation key by email (Your email will only be used for sending evaluation key and follow up your evaluation. We will NEVER share your email to third party without your approval).


Oracle is U.S. registered trademark of Oracle Corporation

Rate this Article

Click on one of the stars below to rate this article from 1 (lowest) to 5 (highest).

You may be interested in

  1. Oracle database design with Entity Relationship Diagram
  2. Oracle Database Design Tool
  3. Oracle database reverse engineering
    Tagged:
  4. Relational Database Design with ERD
  5. Generate class diagrams from entity relationship diagrams
    Tagged:
Tags of this article:

Comments (0)

Write comment

Rating

Comment

Enter the calculation result

security code