Adding Jars to Hibernate


Adding Jars to Hibernate

The following procedures must be followed to create the first hibernate application in Eclipse:

1) Creating a java project

You may create the java project by going to the File menu, selecting New, then selecting Java Project from the list of options. Please give it a title (firsthb, for example), and then click Finish to complete the process.

2) Add the hibernation jar files

Add external archives by right-clicking on your project and selecting Build Path. Pick all the jar files in the image below and then click "Open".

3) Make Persistent a class.

Here, we create the same persistent class we have established in the previous topic. A persistent class can be designed by selecting src and clicking on New - Class.

4) For persistent classes, you need to create a mapping file

We'll construct the same mapping file as we did in the last one on this topic. Right-click on src and select "new file" (e.g. employee.hbm.xml) to create the mapping file. Click "OK" to save the file. It must be on the outside of the package to be effective.

5) It is necessary to create a configuration file.

Username, password, and connection URL are all contained in the configuration file. A database table can be created automatically by setting hbm2ddl.auto to true. Dialect class will be discussed in more detail in future sections. Right-click on src and select "new" from the menu—type hibernate.cfg.xml as the name of the configuration file.

6) Create the permanent object retrieval or storage class.

We are simply storing the employee object in the database with this class.