How can I transform Entity-Based diagram to a JPA java code

做~自己de王妃 提交于 2020-01-24 13:11:47

问题


I have class diagram created with "Sparx Enterprise Architect v8.0" and i need to generate JPA-based classes with annotations that reflect relations to use it in the code. The problem is that i can convert it to EJB but not JPA which is required for my task.


回答1:


I don't know this product, however they claim that it:

supports modeling of database schema and automatic generation of DDL scripts for eleven DBMS targets out-of-the-box

Once you have the database schema I believe there are various tools that can reverse engineer it and generate JPA entities. Few random hits in Google:

  • Generating Persistence Mappings from Database Schema
  • Creating JPA entity beans from database tables
  • Object-Relational Mappings: Generating JPA Entities



回答2:


Have a look at the JPA Modeler for Netbeans, will be best fit for your requirement :

generate the database schema and DAO classes from class diagram

You can find the demo here : JPA Modeler Demo - Youtube




回答3:


If you export your model to ecore format, then you can use Texo to generate JPA annotated POJO for your model.




回答4:


G9 plugin from Marketplace in Spring Tool Suit did job.

  1. Install Plugin G9
  2. Select Project (JAVA)
  3. Import "Import Database Model"
  4. Select JDBC Driver (In my case mysql)
  5. Maintain JDBC Connection
    • New
    • Provide Driver Name, Add Jar, Port, Driver Class and connection url along with schema (jdbc:mysql://localhost:3306/{schema_name})
  6. Close JDBC Connection Box
  7. Port, DB Name, User Name and PWD
  8. Fetch

Reference URL https://www.esito.no/produkter/dbimport/



来源:https://stackoverflow.com/questions/8202231/how-can-i-transform-entity-based-diagram-to-a-jpa-java-code

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