---
title: "Hibernate Start 1"
author: "kimnin"
date: "2008-12-16T11:16:13Z"
tags: []
slug: "hibernate-start-1"
draft: false
lastmod: "2008-12-16T11:16:13Z"
id: 294924
url: "https://kimnin.iteye.com/blog/294924"
---

**Book**

 

&lt;?xml version="1.0"?&gt;  
&lt;!DOCTYPE hibernate-mapping PUBLIC  
 "-//Hibernate/Hibernate Mapping DTD 3.0//EN"  
 "[http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd](http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd)"&gt;  
&lt;hibernate-mapping package="org.kimnin.hibernate"&gt;  
 &lt;class name="Book" table="BOOK"&gt;  
  &lt;id name="id" column="BOOK\_ID"&gt;  
   &lt;generator class="native" /&gt;  
  &lt;/id&gt;  
  &lt;property name="name" column="BOOK\_NAME" /&gt;  
 &lt;/class&gt;  
&lt;/hibernate-mapping&gt;

**cfg**

 

&lt;!DOCTYPE hibernate-configuration PUBLIC  
 "-//Hibernate/Hibernate Configuration DTD 3.0//EN"  
 "[http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd](http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd)"&gt;

&lt;hibernate-configuration&gt;  
 &lt;session-factory&gt;  
  &lt;property name="hibernate.connection.url"&gt;  
   jdbc:mysql://localhost:3306/kidocs  
  &lt;/property&gt;  
  &lt;property name="hibernate.connection.driver\_class"&gt;  
   com.mysql.jdbc.Driver  
  &lt;/property&gt;  
  &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;  
  &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt;  
  &lt;property name="dialect"&gt;  
   org.hibernate.dialect.MySQL5InnoDBDialect  
  &lt;/property&gt;  
  &lt;property name="hibernate.show\_sql"&gt;true&lt;/property&gt;  
  &lt;property name="hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;  
  &lt;property name="hibernate.show\_sql"&gt;true&lt;/property&gt;  
  &lt;property name="hibernate.format\_sql"&gt;true&lt;/property&gt;  
  &lt;mapping resource="org/kimnin/hibernate/Book.hbm.xml" /&gt;  
 &lt;/session-factory&gt;

&lt;/hibernate-configuration&gt;

**SchemaExport**

 

new SchemaExport(new Configuration().configure()).create(true, true);