从JPA注释实体类自动生成数据模式 [英] Auto generate data schema from JPA annotated entity classes

查看:271
本文介绍了从JPA注释实体类自动生成数据模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JPA(Hibernate的实现)注释实体类以持久化到关系数据库(MySQL或SQL Server)。有没有简单的方法从注释类自动生成数据库模式(表创建脚本)?

I'm using JPA (Hibernate's implementation) to annotate entity classes to persist to a relational database (MySQL or SQL Server). Is there an easy way to auto generate the database schema (table creation scripts) from the annotated classes?

我仍然在原型设计阶段,并预期频繁的模式更改。我想能够从带注释的代码中指定和更改数据模型。 Grails的类似之处在于它从域类生成数据库。

I'm still in the prototyping phase and anticipate frequent schema changes. I would like to be able to specify and change the data model from the annotated code. Grails is similar in that it generates the database from the domain classes.

推荐答案

可以使用 hbm2ddl 从Hibernate。文档此处

You can use hbm2ddl from Hibernate. The docs are here.

这篇关于从JPA注释实体类自动生成数据模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆