Skip to main content

Hibernate Reverse Engineering Tutorial For Eclipse To Generate Java Classes From Oracle db

This tutorial will lays the ground work and help you learn how to generate your corresponding java entity classes from the database tables alone. Generating the java classes form the db schema via hibernate reverse engineering tools could save you tons of time if you're setting up a new project. I haven't rewritten the steps that's already published by someone, but I've organized them in a way that will be 'practically' helpful for any newbie who cannot get it right directly from the tutorials I've mentioned here. This is more of a kind a log of things I actually did while I referred these tutorials.


1. Download hibernate tools, only tools. From this tutorial in mkyong.com to install hibernate tools.

2. Create a java project 'HibernateExample'.

4. Select the jar file (ojdbc.jar) from lib folder of apache tomcat if required.

5. Click on 'Test Connection' and confirm that you've configured it properly.

6. Create the hibernate.cfg.xml. Enter the fields you know and leave the others blank.

7. Click Apply and then click 'OK' to close the dialog box.

8. Now in the hibernate perspective you can list out you database.

9.Choose "Hibernate Code Generation Configuration" from the tool bar. This is the phase where you generate the hibernate.reveng.xml file. Set-up a new hibernate.reveng.xml file. If you are new you could use the UI for specifying, otherwise you could write your own.
mine looks like

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
  <table-filter match-schema="<DB-NAME>" match-name="<TABLE1>"/>
  <table-filter match-schema="<DB-NAME>" match-name="<TABLE2>"/>
</hibernate-reverse-engineering>


10. In the Exporters tab specify the things (DAO, ENTITY etc) that you want to generate.

11. Click on the 'Run' button and you are done.

Things to Check When Changing DB

Make sure that u right click this file > 'Edit Configuration' and give the new db configuration in the appearing window.


Best Book To Learn Hibernate ( from what I've read so far)

Other Popular Hibernate Books




Each post takes two days or more of research and three hours of typing to bring out the high quality you see here. If you admire my effort, consider giving +1 to this post and Subscribe me in Facebook.  You can also Follow Me on Twitter

Popular posts from this blog

ICFAI Sikkim Distance MBA Review From My Experience

After a long research I joined for the ICFAI distance MBA program in 2012. Now I've completed 2 semesters ( as of 2013 ). I wanted to write this review so that people who are looking for a good MBA program can get a hand-on review about the distance MBA offered by the ICFAI Sikkim. I've been through all the cycles of this program and this review might help you make the right choice about the program. This article presents my own ( and unbiased ) view of the program and is in no way associated with the course provider.


Is the MBA ICFAI Sikkim Approved By UGC?  As per the latest AICTE regulations, a distance education program must have the approval of a joint commission of  UGC- University Grant CommissionAICTE- All Indian Council for Technical EducationDEC- Distance Education CouncilICFAI Sikkim doesn't have this approval (don't get disappointed, it's not over yet). Only institutes and colleges affiliated to a University are required to take AICTE approval. So ICFAI be…

Is MacBook Air Good For Programming / Blogging ?

I'm a passionate java developer who just migrated from a Windows PC netbook ( Dell mini ) to a 13 inch MacBook Air. Before the netbook I owned a Dell inspirion 1501. I'm quite a bit of an avid blogger as well. I purchased Dell mini just as it was launched hoping that it's compact and mobile architecture would solve all of my need as a programmer and a writer. Unfortunately it turned out that it was a worthless device.The rest of the story goes...



Do Not Compare a Netbook With MacBook AirMacBook's astonishing features far exceeds anything that of a normal Netbook.Before
Buying a netbook for programming and blogging was one of the biggest blunders I ever made on choosing a machine. The screen was 11 inch and clumsy icons of the Windows were a disgrace all the time.The tightly arranged keys in the keyboard made typing a pain. It's slow Intel Atom Processor is too sluggish to run even VLC player.


After  The Mac's backlit spacious keyboard layout, 1440x900 resolution d…

Best Places To Eat at Trivandrum

Are you searching for the most amazing places to eat at Trivandrum? Well, this article is a collection of places from where I've carried the taste after eating. All of them are located in Trivandrum. There is no specific focus for a single kind or restaurant, I've written about the latest hot-spot cafes to ethnic and traditional places at the heart of the city and people for decades.
General Places Azad Hotel Azad Hotel is a hotel-chain all over India and they are one of the best hotels in Trivandrum too. They claim to have introduced the popular dish 'biriyani' in India. However, they provide a good ambience and tasty food. There are all kind of popular non-vegetarian dishes available here. They have a long tradition of serving quality food and that's what makes them the best. There are
Zam Zam This is the most sought after destination in city for the best cooked chicken dishes. The 'Shawai' is the all time best seller of Zam Zam. It's very rushy alwa…