Eclipse generates hbm.xml and entity classes through hibernate tools reverse engineering

Source: Internet
Author: User
Tags jboss

1. Add hibernate tools to your eclipse

Plugin add way: http://download.jboss.org/jbosstools/updates/stable/kepler/-"* Abridged JBoss Tools--" Hibernate tools 3.7.1

2. Upper right Corner open perspective (View menu)

Add database development View and open

Select Database Connections Right-click New to select the appropriate databases (MySQL or Oracle below)

Need to declare drivers-after selecting a database

Then there are three things to do:

A. Select the database version and name (to be used below)

B. Adding a jar package

|--mysql add MySQL core pack Mysql-connector-java ...

|--oracle Add Oracle Core Pack Ojdbc6_g.jar (I'm using 11g)

C.properties Adding related configuration information

Mysql::

Connection url:jdbc:mysql://localhost:3306/< Database name >

Databases Name: Database name

Driver Class:com.mysql.jdbc.Driver

Password: Password

User ID: Username

Oracle::

Catalog: I don't know what's useful.

Connection URL:jdbc:oracle:thin: @localhost:1521:< Database name >

Databases Name: Database name

Driver Class:oracle.jdbc.OracleDriver

Password: Password

User ID: Username

This allows us to complete the connection to the database and we can manipulate the data directly at Eclipse, which is slow

3. Back to Java View

A. Creating a Web project

B. Open the menu bar window--"Show views-" open Hibernate-"Display view hibernate configurations

C. View Hibernate configurations Right-click Add Configuration ...

name--We're going to use it next.

Configuring the Type--hibernate version

project--Select the project

Database connection--The name we configured in the previous step

Property file--Create Hibernate.properties

Configuraction file--Create hibernate.cfg.xml (it itself creates this file with less <property name= "dialect" > org.hibernate.dialect.oracledialect</property>)

Switch to common

Select the encoding Utf-8

So the third step is configured.

4. There is a run Hibernate.cfg.xml on my toolbar

Click the dropdown-"Hibernate Code Generation Configurations

Create a new new configuration

Console configuration--Select the name that you configured in the previous step

Output directory--Select the exported project name

Click Reverse Engineer from JDBC Connection

package--the exported package

reveng,xml--where to put the exported Reveng.xml file

The build will enter configure table filters

After selecting the console configuration refresh (it will take a while), then select the database or the table to operate

Switch to exporters

Select Domain Code and Hibernate XML Mappings

The last click of Run will generate

Note: I imported the jar package in addition to the appeal jar package, but also added Hibernate-core.jar, so I am not sure whether it is necessary (a little lazy today)

Eclipse generates hbm.xml and entity classes through hibernate tools reverse engineering

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.