Share on Google+Share on Google+

Rahul Dev
Configuring Hibernate
1 Answer(s)      6 years and 6 months ago
Posted in : Hibernate

How to configure Hibernate?

Ads

View Answers

October 26, 2010 at 3:10 PM


  1. The configuration files hibernate.cfg.xml and
  2. Mapping files *.hbm.xml

are used by the Configuration class to create the SessionFactory which in turn creates the Session instances.

hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
      <property name="hibernate.connection.driver_class">

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

jdbc:mysql://localhost/hibernatetutorial</property>
      <property name="hibernate.connection.username">root</property>
      <property name="hibernate.connection.password"></property>
      <property name="hibernate.connection.pool_size">10</property>
      <property name="show_sql">true</property>
      <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
      <property name="hibernate.hbm2ddl.auto">update</property>
      <!-- Mapping files -->
      <mapping resource="sample.hbm.xml"/>
</session-factory>
</hibernate-configuration>

sample.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class name="roseindia.tutorial.hibernate.Contact" table="CONTACT">
   <id name="id" type="long" column="ID" >
   <generator class="assigned"/>
  </id>

  <property name="firstName">
     <column name="FIRSTNAME" />
  </property>
  <property name="lastName">
    <column name="LASTNAME"/>
  </property>
  <property name="email">
    <column name="EMAIL"/>
  </property>
 </class>
</hibernate-mapping>









Related Tutorials/Questions & Answers:
Configuring Hibernate
Configuring Hibernate  How to configure Hibernate?   ...; <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd
I am having problem with configuring Hibernate sessionfactory. Please Help
I am having problem with configuring Hibernate sessionfactory. Please Help  Sir, I am having problem with configuring Hibernate sessionfactory.. I was using the old version of Hibernate before now I am using Hibernate 4
Advertisements
Configuring Log4J
Configuring Log4J  Is it possible to configure xml file in such a way that it has different logging levels for diferent packages in java through Log4J
Installing the Driver and Configuring the CLASSPATH
Installing the Driver and Configuring the CLASSPATH  What is the procedure to Installing the Driver and Configuring the CLASSPATH mysql jdbc connector? the jar file
hibernate jndi
In this section, you will learn about configuring hibernate to connect to database via JNDI datasource
configuring a dll file in java.library.path
configuring a dll file in java.library.path  I am unable to configure .dll file in java.library.path in myeclipse ide tool
configuring websphere - WebSevices
configuring websphere  How to configure websphere in eclipse  Visit This Link adopt same kind of operation http://www.myeclipseide.com/documentation/quickstarts/blueedition/blue_connectors/ Thanks Rajanikant
About configuring Servlet
About configuring Servlet  Hi I culdn't run Apache Tomcat (i already installed Tomcat 5.0 version) on Internet Browser.when i finished installing Tomcat i typed http://local host:8080/ in the internet Browser
configuring ready-made struts application - Struts
configuring ready-made struts application  I have a source of Struts project (web based apps) and need to configure it in order to be accessed via... and Hibernate. Other than that, not much I know. I've been trying to follow
configuring cron job - JSP-Servlet
configuring cron job  i decided to use cron job in ubuntu to send automatic mail.i programmed one jsp file that file will call a javafile, that javafile will check whether the client registration is going to expire
Hibernate Configuration files
: In the older version of Hibernate this file was used for configuring ORM... necessary for configuring the Hibernate ORM runtime. In most of the cases...Hibernate Configuration files - Learn about the files in the Hibernate
Hibernate Tutorials
examples. Hibernate tutorials starts from the basics of configuring hibernate...Hibernate Tutorials Hibernate is popular open source object relational mapping... to providing mapping of Java classes to database tables, Hibernate also
Installing and configuring Tomcat server - Java Beginners
Installing and configuring Tomcat server  How to install and configure Tomcat server on desktop  Hi Friend, Please visit the following link: http://www.roseindia.net/web-application-server/tomcat/install
HIBERNATE
HIBERNATE   What is difference between Jdbc and Hibernate
hibernate
hibernate  what is hibernate flow
hibernate
hibernate  what is hibernate listeners
hibernate
hibernate  what is hibernate why we use
Hibernate
Hibernate  hibernate delete query execution
hibernate
hibernate  how to uses optional column in hibernate
Hibernate
Hibernate  how to use pagination concept in Hibernate
hibernate
hibernate  please give me the link where i can freely download hibernate software(with dependencies)   Learn hibernate, if you want to learn hibernate, please visit the following link: Hibernate Tutorials
hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application
hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application
hibernate
why hibernate?  why hibernate?   Hibernate: -Hibernate... library. It solves object-relational impedance mismatch problems. Hibernate makes the application development process easy Hibernate saves the development
Hibernate
Hibernate  Please tell me the difference between hibernate and jdbc
hibernate
hibernate  why we should use hibernate projection
hibernate
hibernate  pls give one simple example program for hibernate
Hibernate
Hibernate  How do you handle parent - child tables relationships in hibernate? How do you handle Detach state in hibernate
hibernate
hibernate  how to execute a sequence(in database) from Hibernate program or java program   Please visit the following link: Hibernate Tutorials
hibernate
hibernate  can any one one explain what is hibernate ?   Please visit the following link: Hibernate Tutorials
Hibernate
Hibernate  hello, how to run hibernate program in netbeans?please send me step by step instructions to run hibernate in netbeans
Tutorials   
Java Spring Hibernate Struts Training java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based! org.hibernate.validator cannot be resolved error java.lang.ClassNotFoundException: org.hibernate.cache.TimestampsRegion java.lang.ClassNotFoundException: org.hibernate.cache.TimestampsRegion property hibernate.cache.region.factory_class is not given Hibernate example step by step in Eclipse with MySQL How to make Struts Hibernate and Spring Based Login/Registration Application? What is the use of Hibernate Native SQL? What is the use of Hibernate is used? How to integrate Struts and Hibernate in an application? How to create the program in Java for getting the forgotten Password Form? How to write create JPA Many-to-Many Relationship in Java? What is the DAO Layer in any application? What is Spring Struts Hibernate DAO Layer? How to write Example code for CRUD application in hibernate annotation? Where to update the Hibernate tools? Query conversion convert into hql how to convert sql into hql package org.hibernate.util does not exist C3P0 with Hibernate What do you understand by JPA? Hibernate Query Checker Jpa many to many relationship What do you understand by Hibernate in Java? What are criteria Queries in Hibernate? How to use Associations and Joins in Hibernate? Hibernate 4 Example with Eclipse How to learn Hibernate? What is Hibernate Framework? hibernate faq 15/03/14 hibernate 15/03/2014 Hibernate Criteria Wildcard how to add mulitiple projections this is a hibernate question this is a hibernate question this is a hibernate question how to writw connection pool coding Hibernate 4.3 and JPA 2.1 support How to create Hibernate session factory name? Can you provide me Hibernate configuration tutorial? I want to build sessionfactory in hibernate 4. Need help. I want to learn Hibernate tutorial quickly How to create sessionfactory in Hibernate 4.1.1? How to create sessionfactory in Hibernate 4.1? Hibernate 4.3.0.Final get session How to learn hibernate in 24 hours? hibernate 4.3.0 I want to know how can I create sessionfactory in hibernate 4 (latest version) standard serviceregistrybuilder example

Ads

 
Advertisement null

Ads