15
About Hibernate The hibernate3.jar contains all the core hibernate files. To use Hibernate, it is required to create Java classes that represents the table in the database and then map the instance variable in the class with the columns in the database. Then Hibernate can be used to perform operations on the database like select, insert, update and delete the records in the table. Hibernate automatically creates the query to perform these operations. CLK application follows the following flow from user interface to database. JSP Page Struts- config.xml Action Class Service Bean Service Implementati on HibernatePers

Hibernate material

Embed Size (px)

DESCRIPTION

Hibernate material

Citation preview

About Hibernate

The hibernate3.jar contains all the core hibernate files. To use Hibernate, it is required to create Java classes that represents the table in the database and then map the instance variable in the class with the columns in the database. Then Hibernate can be used to perform operations on the database like select, insert, update and delete the records in the table. Hibernate automatically creates the query to perform these operations.

CLK application follows the following flow from user interface to database.

JSP Page

Struts-config.xml

Action Class

Service Bean

Service Implementation

HibernatePersistenceManagerImpl

Database

The following are the three main elements of hibernate in CLK application.

1. ServiceConfiguration_DEV_H9.xml

In the above configuration file we specified database connection information, mapping resource detail, dialect property (org.hibernate.dialect.DB2Dialect). The mapping resource property is the mapping for the database table.

This attempts to load the env.properties file from the classpath. This is an environment specific file that contains property values that can be referenced here in this spring configuration file.

classpath:/MAPQ.properties

classpath:/env.properties

Database connection detail

org.hibernate.dialect.DB2390Dialect

false

SH9DBC

org.hibernate.transaction.CMTTransactionFactory

org.hibernate.transaction.WebSphereExtendedJTATransactionLookup

This hibernate.dialect property indicates the particular SQL variant that Hibernate generates.

The hibernate.show_sql option, if set to true will display all the executed SQL queries on the console.

Mapping Resource property detail

com/td/bm/creditlink/domain/application/appraisal/sys/AppraisalContact.hbm.xml

Import the environment specific context file and resources

2. XXX.hbm.xml

This file is used to map class object to table object in the database. In the mapping file, we need to add element that will map the extra property to the database by specifying the column name. In database, it will take an identifier of the parent to be stored.

Example: AppraisalContact.hbm.xml