Results 1 to 6 of 6

Thread: How to configure hibernate?

  1. #1
    Join Date
    May 2009
    Posts
    637

    How to configure hibernate?

    Hello everybody, I am java programmer and i have came across hibernate now. Though i am beginner in this programming world. I want to use hibernate in my java project. I know little bit about this hibernate but still it would be helpful for me if somebody can tell me that how to configure hibernate.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Hibernate is configured in two steps.

    Hibernate is the service which helps you to make difference between the front end and back end of your application. Basically hibernate is configured in two steps. First step is to configure the hibernate service. Configuring the hibernate service includes database connection parameters, collection of persistent classes and caching. And second step is to provide information about the classes to be persisted. These classes would be helping you to bridge gaps between the class and databases.

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Configure hibernate by hibernate.properties or hibernate.cfg.xml

    If you want to configure the hibernate on your computer then you may do it by by using one of the configurations file provided by the hibernate. There are two configurations file in order to configure the hibernate, One is hibernate.properties which is a standard java properties file and second is hibernate.cfg.xml. Both of these file performs the same functions. If you application classpath contains these both files then hibernate.cfg.xml overrides the settings found in the hibernate.properties file.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    What hibernate.cfg.xml contains.

    Here is the code written in hibernate.cfg.xml file to configure the hibernate in a particular application.
    hibernate.cfg.xml

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    <session-factory>
    <property name="connection.url">jdbc:derby://localhost:1527/SampleDB
    </property>
    <property name="connection.username">root
    </property>
    <property name="connection.driver_class">org.apache.derby.jdbc.ClientDriver
    </property>
    <property name="dialect">org.hibernate.dialect.DerbyDialect
    </property>
    <property name="connection.password">root
    </property>
    <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory
    </property>
    <property name="current_session_context_class">thread
    </property>
    <property name="hibernate.show_sql">true
    </property>
    </session-factory>
    </hibernate-configuration>

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Hibernate provided JDBC connections.

    If you are making an application with the hibernate provided JDBC connections then your hibernate configuration file must have the following properties.
    1. connection.driver_class which will be containing the JDBC connection class for the specific database.
    2. connection.url which represents full JDBC URL to the database.
    3. connection.username which will be used to connect to the database.
    4. connection.password to authenticate the username.
    5. dialect specifying the name of the SQL dialect for the database.

  6. #6
    Join Date
    Feb 2008
    Posts
    1,852

    Configuring hibernate by using XML file.

    You can configure the hibernate in your application by using XML files. This is the simplest and widely used approach. There are total two types of configuration that you can do using XML files. one is non-managed environment and another one is for managed environment. In managed environment, You can use source of database to establishing connection rather then specifying all the properties in the configuration file.

Similar Threads

  1. Computer Won't Hibernate
    By Kishan in forum Windows XP Support
    Replies: 3
    Last Post: 18-06-2010, 01:18 AM
  2. key combination to hibernate
    By Arlo1 in forum Windows XP Support
    Replies: 5
    Last Post: 13-01-2010, 07:25 AM
  3. XP Won't Wake Up from Hibernate
    By HaloFodder in forum Windows XP Support
    Replies: 1
    Last Post: 06-04-2009, 11:12 PM
  4. hibernate vs. sleep
    By cdsargent in forum Operating Systems
    Replies: 2
    Last Post: 21-11-2008, 11:35 AM
  5. Cannot hibernate
    By Pete in forum Vista Help
    Replies: 3
    Last Post: 07-06-2008, 04:36 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,635,325.78386 seconds with 17 queries