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 
3.hibernate.connection.username:
  • This property hibernate.connection.username specifies database user name.
4.hibernate.connection.password:
  • This property hibernate.connection.password specifies password.



hibernate.cfg.xml file structure


  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE hibernate-configuration SYSTEM 
  3. "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  4.  
  5. <hibernate-configuration>
  6.  
  7. <session-factory>
  8.  
  9. <!-- Related to the connection START -->
  10. <property name="connection.driver_class">Driver Class Name </property>
  11. <property name="connection.url">URL </property>
  12. <property name="connection.user">user name</property>
  13. <property name="connection.password">password</property>
  14. <!-- Related to the connection END -->

  15. <!-- Related to hibernate properties START -->
  16. <property name="show_sql">true/false</property>
  17. <property name="dialet">Database dialet class</property>
  18. <property name="hbm2ddl.auto">create/update or what ever</property>
  19. <property name="hibernate.jdbc.batch_size">hibernate container that every N rows to be
  20. inserted as batch.</property> 
  21. <!-- Related to hibernate properties END-->
  22.  
  23. <!-- Related to mapping START-->
  24. <mapping resource="hbm file 1 name .xml" />
  25. <mapping resource="hbm file 2 name .xml" />
  26. <!-- Related to the mapping END -->
  27.  
  28. </session-factory>
  29.  
  30. </hibernate-configuration>




Example hibernate.cfg.xml. file  for mysql


hibernate configuration file java

 
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE hibernate-configuration SYSTEM 
  3. "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  4.  
  5. <hibernate-configuration><session-factory>
  6.  
  7. <!-- Related to the connection for Test DataBase START -->
  8. <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
  9. <property name="connection.url"> jdbc:mysql://localhost/test</property>
  10. <property name="connection.user">user </property>
  11. <property name="connection.password">password</property>
  12. <!-- Related to the connection END -->
  13.  
  14. <!-- Related to hibernate properties START -->
  15. <property name="show_sql">true/false</property>
  16. <property name="dialet">org.hibernate.dialect.MySQLDialect</property>
  17. <property name="hbm2ddl.auto">create</property>
  18. <property name="hibernate.jdbc.batch_size">50</property>
  19. <!-- Related to hibernate properties END-->
  20.  
  21. <!-- Related to mapping START-->
  22. <mapping resource="hbm_file1.xml" />
  23. <mapping resource="hbm_file2.xml" />
  24. <!-- Related to the mapping END -->
  25.  
  26. </session-factory>
  27. </hibernate-configuration>


Example hibernate.cfg.xml. file for oracle Db

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE hibernate-configuration SYSTEM 
  3. "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  4.  
  5. <hibernate-configuration><session-factory>
  6.  
  7. <!-- Related to the connection for Test DataBase START -->
  8. <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
  9. <property name="connection.url"> jdbc:oracle:thin:@localhost:1521:xe</property>
  10. <property name="connection.user">user </property>
  11. <property name="connection.password">password</property>
  12. <!-- Related to the connection END -->
  13.  
  14. <!-- Related to hibernate properties START -->
  15. <property name="show_sql">true/false</property>
  16. <property name="dialet">org.hibernate.dialect.Oracle9Dialect</property>
  17. <property name="hbm2ddl.auto">create</property>
  18. <property name="hibernate.jdbc.batch_size">50</property>
  19. <!-- Related to hibernate properties END-->
  20.  
  21. <!-- Related to mapping START-->
  22. <mapping resource="hbm_file1.xml" />
  23. <mapping resource="hbm_file2.xml" />
  24. <!-- Related to the mapping END -->
  25.  
  26. </session-factory>
  27. </hibernate-configuration>



Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu