Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Hibernate Configuring Hibernate
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


How to configure Hibernate?


Advertisement
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  how to use pagination concept in Hibernate
hibernate
hibernate  what is hibernate why we use
Hibernate
Hibernate  hibernate delete query execution
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  how to uses optional column 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  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
Advertisements
 

 

 

DMCA.com