如何在S2SH中, 由.hbm.xml文件和POJO类生成数据库表

我的hibernate交给spring管理,如何用现在的**.hbm.xml生成数据库
比如现有如下文件:
数据库名:Test
user.java
user.hbm.xml
application.xml
由这些文件如何生成数据库啊?

首先要在spring.xml里面配置sessionfactory和其他的,sessionfactory里面要制定hbm.xml文件的位置
[code="java"]
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">






org.hibernate.dialect.MySQLDialect

<!-- 表示允许自动提交 -->
true
<!-- 显示sql语句 -->
true
true
<!-- 自动生成表结构
create
-->




classpath:/hibernate



[/code]

用hibernate tools插件,里面有这样的功能。

在hibernate.cfg.xml中添加这句
[code="xml"]
create-drop
[/code]
这样hibernate就会自动建立数据库,并且每添一条数据
他立马就会删掉,如果你有表了,可以改成update,这样就你改什么是什么

package com.zzz.util;

import java.io.File;

import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class ExportDB {
//这是一个导到数据库建表的类;
public static void main(String[] args) {
//读取hibernate.cfg.xml文件;
Configuration cfg=new Configuration().configure(new File("src/hibernate.cfg.xml"));

    //读取hibernate 默认hibernate.properies文件;
    //Configuration cfg=new Configuration();
    SchemaExport export=new SchemaExport(cfg);
    export.create(true, true);
}

}