Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to configure hibernate?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 30-01-2010
Member
 
Join Date: May 2009
Posts: 620
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.

Reply With Quote
  #2  
Old 30-01-2010
Member
 
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.
Reply With Quote
  #3  
Old 30-01-2010
Member
 
Join Date: May 2008
Posts: 2,384
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.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #4  
Old 30-01-2010
Member
 
Join Date: May 2008
Posts: 2,008
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>
Reply With Quote
  #5  
Old 30-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
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.
Reply With Quote
  #6  
Old 30-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,848
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to configure hibernate?"
Thread Thread Starter Forum Replies Last Post
Computer Won't Hibernate Kishan Windows XP Support 3 18-06-2010 02:18 AM
key combination to hibernate Arlo1 Windows XP Support 5 13-01-2010 07:25 AM
XP Won't Wake Up from Hibernate HaloFodder Windows XP Support 1 07-04-2009 12:12 AM
hibernate vs. sleep cdsargent Operating Systems 2 21-11-2008 11:35 AM
Cannot hibernate Pete Vista Help 3 07-06-2008 05:36 PM


All times are GMT +5.5. The time now is 03:53 AM.