---
title: "利用hibernate的映射逆向生成数据库表"
author: "tianmo2008"
date: "2009-10-08T01:30:35Z"
tags: ["Hibernate", "Java", "XML"]
slug: "hibernate"
draft: false
lastmod: "2009-10-08T01:30:35Z"
id: 482729
url: "https://chjl2020.iteye.com/blog/482729"
---

用hibernate,除了可以根据数据库生成对应的po,也能逆向根据po生成对应的数据库表, 首先是要建好一个空数据库,接着给加一个属性 \[code="xml"] create \[/code] 再执行如下代码 \[code="java"] //装载配置文件 Configuration cfg = new Configuration().configure(); SchemaExport export = new SchemaExport(cfg); export.create(true, true); \[/code]