Hibernate Tools Quick Start

The intent to write this entry is to help new comers while playing with Hibernate Tools to generate Domain objects, Daos, .hbm files and other artifacts from database schema.

Preliminary Steps

  1. Create a maven or Java project with dependencies on mysql, hibernate and spring libraries
  2. Install Mysql and create appropriate schema.
  3. Create credentials on mysql for created schema
  4. If created using maven, run goal “install” as well.

Mentioned below are the steps to create domain objects

  1. Create .cfg file.
    - Follow the screenshot below to create appropriate .cfg file

    image image image

  2. Create Console Configuration
    - No need to modify anything and just click on Finish
    image
    image

    Open Hibernate perspective and the red marked db schema should appear on left side.

  3. Create Reverse Engineering file
    - Create a reverse engineering file, using wizard.
    - The only thing that is important here is to choose all required tables in “Add Tables and Columns” section.

    image

  4. Run console configuration
    - The console configuration is actually the artifact, which we are going to run and based on final settings mentioned in that, code will get generated.
    - The configuration can be run through a new icon as shown in the below screenshot

    image 

Advertisement

About hmblogs

IT professional as a J2EE Consultant
This entry was posted in Technology and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s