Hibernate Tools & Reverse Engineering the Following Steps Show How

Preview:

Citation preview

Hibernate Tools & Reverse Engineering

The following steps show how to configure and use hibernate tool eclipse plug-in to generate POJOs using reverse engineering.

1. Create a New Project

2. Add required jar files. And configure them in build path.

3. Open Hibernate Perspective

4. Add Configuration

5. Database Connection: New

Next

Finish.

6. Mention the property file. If no file present, you can create one now. Mention the config file which is the hibernate.cfg.xml. If no file is present, you can create one now.

Finish.

At this point you can see the db config and the config files generated.

7. Now we need to create config file for reverse engineering. hibernate-revenge.xml

Open Hibernate Code Generation Configuration to create a new config.

8. Create new revenge.xml

Choose exports

Apply Run.

Pojos are generated in src.com.entity package.

For more info refer the urls:http://docs.jboss.org/tools/3.0.0.GA/en/hibernatetools/html/reverseengineering.html#d0e4021 https://www.hibernate.org/hib_docs/tools/reference/en/html/setup.html

Troubleshooting:1. At times when you don’t see the database tables in Hibernate Perspective

a. Check the hibernate configurationi. Is the Default Namespace correctly configured?

ii. Is the right hibernate.cfg.xml used?b. Check if you have included the necessary jar files in the classpath.

2. If you are not happy with the Naming Convention of the generated Class files: You can mention the Class file name in the hibernate-revenge.xml

3. There is no need to specify sessionFactory name. At times errors occur when you specify name to sessionFactory, so check with that.

4. If you need to use Generics, then In Exporters tab, check the User Java 5 Syntax checkbox.

Recommended