- Install JBoss Tools on Eclipse using update site
In Eclipse Indigo, on menu bar, click Help / Install new Software
Paste this address in Work with text field and click Add... http://download.jboss.org/jbosstools/updates/development/indigo/
The mandatory plugin is JBoss Data Services / Hibernate tools, but it is good to install all of them - Create a Hibernate Configuration
Open Hibernate Perspective
In Hibernate Configurations panel, right click in a empty space and go to Add Configuration
In Project field, select the project where Java classes will be created.
In Database Connection combo box select an existent MySql connection or create a new one clicking on New button.
In Property file field, click in Setup / Create new
In Configuration file field, click in Setup / Create new
Click OK - Run Hibernate Code Generation
Edit hibernate.cfg.xml file. Remove name property on session-factory tag. Let it with no attributes.
Add hibernate-tools.jar to the project classpath. It can be found at <eclipse installation folder>\plugins\org.jboss.tools.hibernateextension4_0_3.4.0.v20111213-1944-H40-M5\lib\tools
On Hibernate perspective, on menu bar, click Run / Hibernate Code Generation / Hibernate Code Generation Configurations
In Console configuration, select the just created configuration
In Output directory, select the source root folder
In Package, type desired package
In revenge.xml, click Setup / Create new
In reveng. strategy, Browse to the class org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy
Click Run button - Check generated classes out
Open Java EE perspective
Refresh project files
See that entity and DAO classes were generated
Wednesday, January 4, 2012
How to generate Java classes for Hibernate from MySql database tables using Eclipse Indigo
Labels:
Code Generation,
Eclipse Indigo,
Hibernate,
Java classes from tables,
JPA,
MySql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment