· 10 years ago · Apr 01, 2016, 03:03 PM
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!DOCTYPE hibernate-configuration PUBLIC
4"-//Hibernate/Hibernate Configuration DTD//EN"
5"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
6
7<hibernate-configuration>
8
9 <session-factory>
10
11 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
12 <property name="hibernate.connection.class_driver">com.mysql.jdbc.Driver</property>
13 <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/tpproject</property>
14 <property name="hibernate.connection.username">root</property>
15 <property name="hibernate.connection.password"></property>
16 <property name="hibernate.connection.pool_size">20</property>
17 <property name="hibernate.show_sql">true</property>
18 <mapping resource="dao/config/ville.hbm.xml" />
19 </session-factory>
20
21</hibernate-configuration>
22
23<?xml version="1.0" encoding="utf-8"?>
24<!DOCTYPE hibernate-mapping PUBLIC
25 "-//Hibernate/Hibernate Mapping DTD//EN"
26 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
27<hibernate-mapping>
28 <class name="model.Ville" table="t_ville">
29 <id name="id" type="int" column="id_v">
30 <generator class="assigned"/>
31 </id>
32 <property name="nom" column="nom_v" type="string"/>
33 </class>
34</hibernate-mapping>
35
36package model;
37
38public class Ville {
39
40 private int id;
41 private String nom;
42
43 public Ville() {
44 super();
45 }
46
47 public Ville(int id, String nom) {
48 super();
49 this.id = id;
50 this.nom = nom;
51 }
52
53 public void setId(int id) {
54 this.id = id;
55 }
56 public int getId() {
57 return id;
58 }
59 public void setNom(String nom) {
60 this.nom = nom;
61 }
62 public String getNom() {
63 return nom;
64 }
65}
66
67`CREATE TABLE IF NOT EXISTS `t_ville` ( `id_v` int(11) NOT NULL, `nom_v` varchar(50) DEFAULT NULL, PRIMARY KEY (`id_v`) )`