1.hibernate.dialect:
- This property hibernate.dialect makes Hibernate generate the appropriate SQL for the given database.
2.hibernate.connection.driver_class:
- This property hibernate.connection.driver_class specifies jdbc driver class name
- This property hibernate.connection.username specifies database user name.
- This property hibernate.connection.password specifies password.
hibernate.cfg.xml file structure
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE hibernate-configuration SYSTEM
- "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
- <hibernate-configuration>
- <session-factory>
- <!-- Related to the connection START -->
- <property name="connection.driver_class">Driver Class Name </property>
- <property name="connection.url">URL </property>
- <property name="connection.user">user name</property>
- <property name="connection.password">password</property>
- <!-- Related to the connection END -->
- <!-- Related to hibernate properties START -->
- <property name="show_sql">true/false</property>
- <property name="dialet">Database dialet class</property>
- <property name="hbm2ddl.auto">create/update or what ever</property>
- <property name="hibernate.jdbc.batch_size">hibernate container that every N rows to be
- inserted as batch.</property>
- <!-- Related to hibernate properties END-->
- <!-- Related to mapping START-->
- <mapping resource="hbm file 1 name .xml" />
- <mapping resource="hbm file 2 name .xml" />
- <!-- Related to the mapping END -->
- </session-factory>
- </hibernate-configuration>
Example hibernate.cfg.xml. file for mysql
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE hibernate-configuration SYSTEM
- "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
- <hibernate-configuration><session-factory>
- <!-- Related to the connection for Test DataBase START -->
- <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
- <property name="connection.url"> jdbc:mysql://localhost/test</property>
- <property name="connection.user">user </property>
- <property name="connection.password">password</property>
- <!-- Related to the connection END -->
- <!-- Related to hibernate properties START -->
- <property name="show_sql">true/false</property>
- <property name="dialet">org.hibernate.dialect.MySQLDialect</property>
- <property name="hbm2ddl.auto">create</property>
- <property name="hibernate.jdbc.batch_size">50</property>
- <!-- Related to hibernate properties END-->
- <!-- Related to mapping START-->
- <mapping resource="hbm_file1.xml" />
- <mapping resource="hbm_file2.xml" />
- <!-- Related to the mapping END -->
- </session-factory>
- </hibernate-configuration>
Example hibernate.cfg.xml. file for oracle Db
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE hibernate-configuration SYSTEM
- "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
- <hibernate-configuration><session-factory>
- <!-- Related to the connection for Test DataBase START -->
- <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
- <property name="connection.url"> jdbc:oracle:thin:@localhost:1521:xe</property>
- <property name="connection.user">user </property>
- <property name="connection.password">password</property>
- <!-- Related to the connection END -->
- <!-- Related to hibernate properties START -->
- <property name="show_sql">true/false</property>
- <property name="dialet">org.hibernate.dialect.Oracle9Dialect</property>
- <property name="hbm2ddl.auto">create</property>
- <property name="hibernate.jdbc.batch_size">50</property>
- <!-- Related to hibernate properties END-->
- <!-- Related to mapping START-->
- <mapping resource="hbm_file1.xml" />
- <mapping resource="hbm_file2.xml" />
- <!-- Related to the mapping END -->
- </session-factory>
- </hibernate-configuration>
No comments