hibernate tools & reverse engineering the following steps show how

14
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

Upload: f2003027

Post on 18-Nov-2014

742 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Hibernate Tools & Reverse Engineering the Following Steps Show How

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

Page 2: Hibernate Tools & Reverse Engineering the Following Steps Show How

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

3. Open Hibernate Perspective

Page 3: Hibernate Tools & Reverse Engineering the Following Steps Show How

4. Add Configuration

Page 4: Hibernate Tools & Reverse Engineering the Following Steps Show How

5. Database Connection: New

Page 5: Hibernate Tools & Reverse Engineering the Following Steps Show How

Next

Finish.

Page 6: Hibernate Tools & Reverse Engineering the Following Steps Show How

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.

Page 7: Hibernate Tools & Reverse Engineering the Following Steps Show How

Finish.

Page 8: Hibernate Tools & Reverse Engineering the Following Steps Show How

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

Page 9: Hibernate Tools & Reverse Engineering the Following Steps Show How

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

Open Hibernate Code Generation Configuration to create a new config.

Page 10: Hibernate Tools & Reverse Engineering the Following Steps Show How

8. Create new revenge.xml

Page 11: Hibernate Tools & Reverse Engineering the Following Steps Show How

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

Page 12: Hibernate Tools & Reverse Engineering the Following Steps Show How

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.