从 JPA 实体逆向工程 DDL [英] Reverse engineer DDL from JPA entities

查看:28
本文介绍了从 JPA 实体逆向工程 DDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩一些 JPA 的东西,更改映射以查看它们应该如何等等.这是基本的实验.但是,我找不到可以简单地读取我的实体然后为我生成表模式的工具.我试图在 JBoss 工具中找到类似的东西,但 nada.Eclipse 集成将是一个巨大的优势,但我会使用命令行工具或 ant 任务.

I'm playing around with some JPA stuff, changing the mappings to see how they're supposed to be etc. It's basic experimentation. However I can't find a tool that will simply read my entities and then generate the table schema for me. I tried to find something like this in JBoss tools but nada. Eclipse integration will be a huge plus but i'll take a command line tool or an ant task.

有什么想法吗?

推荐答案

我认为使用 JPA 并没有通用的方法可以做到这一点,您必须直接使用底层 JPA 实现来实现这一点.

I don't think there is an universal way of doing this with JPA, you have to directly use the underlying JPA implementation to achieve this.

对于休眠,有几种可能:

  • Use the method duffymo posted earlier, that makes Hibernate update the database schema automatically.
  • If you do not want that, you can use the hbm2ddl tool from Hibernate Tools (note: link sucks, but apparently their home page is a bit broken right now). You can use that to automatically generate database creation scripts from your JPA entities; there are also plugins for Maven and Ant that invoke hbm2ddl automatically.

对于 EclipseLink(以前称为 Oracle TopLink,JPA 2.0 RI),请参阅 使用 EclipseLink JPA 扩展进行模式生成.原则上它与 Hibernate 非常相似,尽管乍一看我没有看到任何可以用作创建数据库脚本的独立实用程序.

For EclipseLink (formerly Oracle TopLink, the JPA 2.0 RI) see Using EclipseLink JPA Extensions for Schema Generation. In principle it is very similar to Hibernate, although at first glance I don't see anything that could be used as a stand-alone utility for creating a DB script.

其他 JPA 实现(BEA/Oracle Kodo、Apache OpenJPA)可能有自己的特定方法来实现这一点.

Other JPA implementations (BEA/Oracle Kodo, Apache OpenJPA) probably have their own specific methods of achieving this.

这篇关于从 JPA 实体逆向工程 DDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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