从 JPA 实体逆向工程 DDL

编程入门 行业动态 更新时间:2024-10-27 18:27:37
本文介绍了从 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.

对于休眠,有几种可能:

使用之前发布的方法 duffymo,这使得Hibernate 自动更新数据库架构.如果您不希望那样,您可以使用 Hibernate Toolshbm2ddl 工具/a>(注意:链接很烂,但显然他们的主页现在有点坏了).您可以使用它从 JPA 实体自动生成数据库创建脚本;还有用于 Maven 和 Ant 的插件可以自动调用 hbm2ddl. 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屋!

更多推荐

[db:关键词]

本文发布于:2023-03-28 02:42:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/716207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   工程   JPA   DDL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!