简体   繁体   English

春天的靴子。从MySql架构自动创建实体类

[英]Spring boot. Automatically create Entity classes from MySql schema

I have been working on EER diagram model for my Mysql base for the last 7 days. 在过去的7天里,我一直在研究我的Mysql基础的EER图模型。 It is a rather complicated model with lots of connections and attributes. 它是一个相当复杂的模型,具有许多连接和属性。 Now i know spring boot automatically creates tables based on your entity classes(including foreign keys and other settings) if you use spring.jpa.hibernate.ddl-auto = update in your application.properties, but is it possible to create entity classes after providing good credentials to DataSource object based on tables withing schema? 现在我知道spring boot会根据你的实体类(包括外键和其他设置)自动创建表,如果你在application.properties中使用spring.jpa.hibernate.ddl-auto = update,但是可以在之后创建实体类基于具有模式的表为DataSource对象提供良好的凭据?

Point is i would probably need another 3-4 days of back-end coding to create all the classes with all the attribute, relationships etc. 点是我可能需要另外3-4天的后端编码来创建具有所有属性,关系等的所有类。

Given the fact it can only be done in one correct way, based on schema tables and it is not really rocket science. 鉴于它只能以一种正确的方式完成,基于模式表并且它不是真正的火箭科学。 Why not do the thing just once? 为什么不做一次呢?

There is this question Automatically create Entities from database but 1. i am using spring boot not JPA project and second blog is no longer active. 有这个问题从数据库自动创建实体但是1.我使用的是spring boot而不是JPA项目,而第二个博客不再有效。

Any hints? 任何提示?

Just figured it out. 刚想通了。 I used the hibernate perspective in eclipse to connect to a database, create a cfg.xml and run the project as hibernate configurations, create a new reveng.xml config and that will work. 我使用eclipse中的hibernate透视图连接到数据库,创建cfg.xml并将项目作为hibernate配置运行,创建一个新的reveng.xml配置,这将起作用。 More detailed answer can be found in the article below. 更详细的答案可以在下面的文章中找到。

http://o7planning.org/en/10125/using-hibernate-tools-generate-entity-classes-from-tables http://o7planning.org/en/10125/using-hibernate-tools-generate-entity-classes-from-tables

Hope it will help someone!! 希望它会帮助别人!!

There is this question Automatically create Entities from database but 1. i am using spring boot not JPA project and second blog is no longer active. 有这个问题从数据库自动创建实体但是1.我使用的是spring boot而不是JPA项目,而第二个博客不再有效。

Under the woods, Spring boot uses JPA and more specifically Hibernate since it has bad compatibility with other JPA implmentations such as EclipseLink. 在这种情况下,Spring引导使用JPA,更具体地说是Hibernate,因为它与其他JPA实现(例如EclipseLink)的兼容性很差。

Why don't you use Dali Eclipse plugin ? 你为什么不使用Dali Eclipse插件? https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/tasks006.htm https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/tasks006.htm

It has a wizard with many options and it addresses well this kind of need. 它有一个包含许多选项的向导,它可以满足这种需求。 The real drawback when I use it and we cannot store our orm configuration. 我使用它时的真正缺点是我们无法存储我们的orm配置。 So, since you have many tables, I advise you to generate it in an incremental way your entities. 因此,由于您有许多表,我建议您以增量方式生成实体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 弹簧靴。 如何使用注解创建 TaskExecutor? - Spring boot. How to Create TaskExecutor with Annotation? 无法在java Spring Boot中创建新实体。 得到```无法启动嵌入式容器```错误 - Unable to create a new entity in java Spring Boot. Getting ``` Unable to start embedded container``` error 如何使用 spring 引导从数据库创建实体类? - How to create entity classes from database using spring boot? 弹簧靴。 如何将 Optional&lt;&gt; 传递给实体类 - Spring Boot. how to Pass Optional<> to an Entity Class 无法让spring boot在gradle项目中自动创建数据库模式 - Unable to get spring boot to automatically create database schema in gradle project 无法获取 spring 引导自动创建数据库模式 - Unable to get spring boot to automatically create database schema Spring 开机。 userPrincipal 是 null - Spring boot. userPrincipal is null 弹簧靴。 在 RestController 上转发 - Spring Boot. Forward on RestController Java / Kotlin / Spring Boot。 发生异常时如何自动检索参数值? - Java / Kotlin / Spring Boot. How can we automatically retrieve parameter values when an exception occurs? 弹簧靴。 在修改实体时执行 saveAndFlush 会导致未保存的瞬态异常 - Spring Boot. Doing a saveAndFlush with modifying an entity results to unsaved trancient exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM