• JSP
  • RubyonRails
  • PHP
  • SQL Tutorial
  • Spring
  • Core Java
  • JavaScript
  • jQuery
  • Struts

  • <

    Configuration


    Configuration, Generally written in hibernate.properties or hibernate.cfg.xml files. For Java configuration, you may find class annotated with @Configuration. It is used by Session Factory to work with Java Application and the Database. It represents an entire set of mappings of an application Java Types to an SQL database.

    Hibernate Properties
  • hibernate.dialect: This property makes Hibernate generate the appropriate SQL for the chosen database.
  • hibernate.connection.driver_class: The JDBC driver class.
  • hibernate.connection.url: The JDBC URL to the database instance.
  • hibernate.connection.username: The database username.
  • hibernate.connection.password: The database password.
  • hibernate.connection.pool_size: Limits the number of connections waiting in the Hibernate database connection pool.
  • hibernate.connection.autocommit: Allows autocommit mode to be used for the JDBC con

  • Example

    <?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>

    <property name = "hibernate.dialect">
    org.hibernate.dialect.MySQLDialect
    </property>

    <property name = "hibernate.connection.driver_class">
    com.mysql.jdbc.Driver
    </property>

    <!-- Assume test is the database name -->

    <property name = "hibernate.connection.url">
    jdbc:mysql://localhost/test
    </property>

    <property name = "hibernate.connection.username">
    root
    </property>

    <property name = "hibernate.connection.password">
    root123
    </property>

    <!-- List of XML mapping files -->
    <mapping resource = "Employee.hbm.xml"/>

    </session-factory>
    </hibernate-configuration>
















    © copyright 2017-2021 Completedone pvt ltd.