如何从Java中的sql模式生成orm映射类 [英] How to generate orm mapping classes from sql schema in Java

查看:130
本文介绍了如何从Java中的sql模式生成orm映射类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个db的现有sql模式文件。当需要DAO的实体和所有其他所需的帮助/客户端类访问它时,是否可以生成和重新生成?

I have an existing sql schema file for db. Is it possible to generate and re-generate when needed DAO's entities and all other required helper/client classes to access it? I don't mind what will it be -- hibernate, other jpa or something else.

推荐答案

假设你/别人还在寻找解决方案:

Asuming you/others are still looking for a solution:

我刚刚得到了相同的问题,并使它在Eclipse中工作(略有不同)如下:

I just got the same problem and got it working in Eclipse (slightly different) as follows:


  1. 创建JPA Project并下载&在向导中添加用户库

  2. 还希望将schema-sql文件作为输入,而是找到一种将实际数据库作为输入的方法。 (这对于工具的开发人员来说比解析专有的sql脚本文件更容易多了)

  3. 要做到这一点rightclickyou jpa project an therenew / other / jpa /表中的实体

  4. 在以下向导中,您必须创建一个db连接到您想要作为jpa注释的POJO直观...但你可能会问是否有问题)

  1. created JPA Project and downloaded & added user library in the wizard
  2. Also wanted to give a schema-sql-file as input but instead found a way to take an actual db as input. (That was surely much easier for the developers of the tool to process than parsing proprietary sql-script-files)
  3. To do that "rightclick" you jpa project an there "new/other/jpa/entities from tables"
  4. In the following Wizard you have to create a db-connection to the db whose schema you want to get as jpa-annotated POJOs (IMHO It's very intuitive..but you may ask if there is a problem)

完成所有jpa类后,从db生成... ...从很多地方保存我of dummy work:)

After finishing all jpa-classes are generated from the db...saved me from a lot of dummy work :)

这篇关于如何从Java中的sql模式生成orm映射类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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