从数据库自动创建实体 [英] Automatically create Entities from database

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

问题描述

有没有办法从现有数据库(或从创建它们的SQL语句)自动创建javax.persistence.Entity类?

Is there a way to automatically create javax.persistence.Entity classes from an existing database (or from the SQL statements that created them)?

我只是在阅读通过 Java EE 5教程的持久性部分考虑到所有(或大多数)必要知识已经在数据库中编码或甚至以SQL语句的形式明确给出,并且手工创建所有这些注释似乎相当浪费。

I am just reading through the persistence part of The Java EE 5 Tutorial and creating all these annotations by hand seems rather wasteful considering that all (or most) of the necessary knowledge is already encoded in the database or even explicitly given in the form of SQL statements.

推荐答案

有几种尝试对数据库进行逆向工程来创建实体类,其中一个谷歌搜索结果显示这个博客,但你可以找到很多信息。
此外,如果您打算使用hibernate,请检查ddl2hbm工具,基本上是相同的想法。

There are several attemps to reverse engineer databases to create entity classes, one of the first google results show this blog, but you can find quite a lot information. Also if you are going to use hibernate, check for ddl2hbm tools, what basically is the very same idea.

这篇关于从数据库自动创建实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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