Automatically create Entities from database

不羁的心 提交于 2019-12-24 08:59:15

问题


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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/2356521/automatically-create-entities-from-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!