Hibernate auto-generate. HBM and. Java

Source: Internet
Author: User

This is One of the best descriptions of ' How to ' Hibernate tools to reverse engineer a DB into, hbm and. Ja VA files automatically.

I'll post the description here if it'll ever disappear. Download the Hibernate-tools jar. [i] Extract the jar to plugins folder of Eclipse. Start Eclipse. Click on [File-> New->-> 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 [File-> new->-> Hibernate-> Hibernate console Configuration] and create a New console conf Iguration. ADD the jar file, contains your DB driver in 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->-> 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 is created in the output directory, specified in step 11.

UPDATE: [i] Some of the new versions of Eclipse come with the tools pre installed, if your version has the tools Prein Stalled jump to step 4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.