Configuring Hibernate

Configuring Hibernate

How to configure Hibernate?

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?   ...' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate
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
hibernate jndi
In this section, you will learn about configuring hibernate to connect to database via JNDI datasource
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
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... the variables necessary for configuring the Hibernate ORM runtime. In most...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  how to uses optional column 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  hibernate delete query execution
hibernate
hibernate  what is hibernate why we use
Hibernate
Hibernate  how to use pagination concept in Hibernate
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  pls give one simple example program for hibernate
hibernate
hibernate  why we should use hibernate projection
Hibernate
Hibernate  Please tell me the difference between hibernate and jdbc
Hibernate
Hibernate  hello, how to run hibernate program in netbeans?please send me step by step instructions to run hibernate in netbeans
hibernate
hibernate  can any one one explain what is hibernate ?   Please visit the following link: Hibernate Tutorials
hibernate
hibernate  how to execute a sequence(in database) from Hibernate program or java program   Please visit the following link: Hibernate Tutorials
Hibernate
Hibernate  How do you handle parent - child tables relationships in hibernate? How do you handle Detach state in hibernate
Hibernate - Hibernate
Hibernate Features  Hibernate features in eclipse
hibernate
hibernate  how to impot mysql database client jar file into eclipse for hibernate configuration   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 http://www.roseindia.net/hibernate/runninge-xample.shtml
Hibernate
Hibernate  hi sir i need hibernate complete tutorial for download   Hi Friend, Please visit the following link: Hibernate Tutorials Thanks
Struts - Hibernate Integration
Struts - Hibernate Integration  Hi, I need to integrate the struts with hibernate.. can u pls tell me the process of configuring etc etc WITHOUT... the following link:ADS_TO_REPLACE_2 Struts Hibernate Integration Thanks
hibernate
hibernate  How to know how many columns changed in a table when we are using hibernate
hibernate
hibernate  hi what are the necessary jar files that we need to set in the classpath to execute a hibernate application
HIBERNATE
HIBERNATE  How u connects database using hibernate 3.0? Where you have written the database configuration details
hibernate
hibernate   i am using hibernate3.2.5 and oracle9i. First i set classpath to ojdbc14.jar and all the hibernate jar files to path env variable.After that when i try to execute the program i got an error "unknown oracle major
hibernate
hibernate  Is there any other way to call procedure in hibernate other than named query????? if we are using session object to get the connection then why hibernate we can directly call by using a simple java class??????? please
hibernate
hibernate  when we using schemaExport in hibernate every time it drops the existing table and create new table ,if table contain dependent table then is it drop
Hibernate - Hibernate
Hibernate sessionfactory configuration  What is the process of hibernate sessionfactory configuration
hibernate - Hibernate
hibernate program shareware  hibernate program shareware example
Hibernate
of Hibernate. I followed all th steps as given in the tutorial, but a build error... hibernate library files are not included in the project build path.ADS_TO_REPLACE_1 Please download the example from Hibernate Getting Started Tutorial. Please
Hibernate
Hibernate  Hi i have 2 doubbts regarding Hibernate ,.. 1)Can we rename hibernate.cfg.xml? 2? can we use multiple mapping resource in hibernate.cf.xml file ? pls let me know soon
Hibernate
Hibernate  Can we write more than one hibernate.cfg.xml file... ? if so how can we call and use it.? can we connect to more than one DataBase from a single Hibernate program
hibernate
://www.roseindia.net/hibernate/index.shtml Here you will get lot of examples. ThanksADS
Hibernate - Hibernate
Hibernate application development help  Hi, Can anyone help me in developing my first Java and Hibernate application
Hibernate - Hibernate
prog using hibernate query   Hibernate update query http://www.roseindia.net/hibernate/hibernate-update.shtml This will show you how to update records in hibernate! regards Meeya
hibernate...............
hibernate...............  goodevining. I am using hibernate on eclipse, while connection to database Orcale10g geting error .........driver ARNING: SQL Error: 0, SQLState: null 31 May, 2012 8:18:01 PM

Ads