9

I would like to generate ER diagram from Hibernate entities or Hibernate mapping. I have selected visual paradigm tool which provides this feature. I would like to know your feedback about visual paradigm or some other tools if you know which supports the above feature.

rtruszk
  • 3,902
  • 13
  • 36
  • 53
rahul
  • 383
  • 1
  • 8
  • 20
  • I never used visual paradigm, but I used http://ermaster.sourceforge.net/, it's an eclipse plugin and it generates diagram out of entity. It i simple and handy. – Bala Apr 30 '15 at 02:09
  • @Bala can i draw an er diagram from hibernate mapping using this tool? – rahul Apr 30 '15 at 02:41
  • 1
    Do you have *.hbm.xml files or JPA annotations? With JPA annotations you could use this NetBeans plugin http://plugins.netbeans.org/plugin/53057/jpa-modeler or this Eclipse plugin http://eclipse.org/webtools/dali/ – Simon Martinelli Apr 30 '15 at 08:30
  • I use Visual Paradigm for several years now and I am very satisfied. Although the feature you expect is provided I only use it the other way, drawing diagrams and convert them to hibernate classes and ddls. If something goes wrong, the support team is very helpful and cooperative too. – Vincent Jul 06 '17 at 12:57
  • I knew two, must enver be supported? – Grim Dec 06 '17 at 06:51

2 Answers2

0

If you are using IntelliJ Idea (Ultimate) you can use Persistence Tool Window. In order to use this feature, you have to add Java EE Persistence Framework Support to your project or module. ( Note: To do that, go to Project Tool Window: right-click a module folder and select Add Framework Support.)

For the tool window to be available, there must be a JPA- or Hibernate-enabled module in your project, i.e. a module with a JPA or Hibernate facet.

To open the tool window, do one of the following:

  • Select View > Tool Windows > Persistence
  • If the tool window bars are currently shown, click the Persistence button (normally located at the lower-left part of the workspace).

After that, you can generate persistence mapping. Then Right-click on the generated persistence unit and select “ER Diagram”.

References:

B378
  • 987
  • 2
  • 12
  • 27
-3

Single version of truth

Please do not use the entitys to modify the structure of the database:

  1. if you add a non-null non-default column to a entity the database can not be changed if there are rows in that table because the initial value of that column can not be calculated.
  2. If you add a fk to a table some values might have illegal references. You do not like to have this problems in deployment.

Use the tools of db managers instead please and calculate the entitys from the db.

Grim
  • 1,938
  • 10
  • 56
  • 123
  • What is wrong with a code first approach? Then the single version of truth is the code and you always generate database migrations from the code. You can do this for example with entity framework from Microsoft or with liquibase (`liquibase:diff`) command. We have been using this for years and it works very well. – Guillermo Feb 14 '22 at 08:48
  • @Guillermo I dont know the "Microsoft Entity Framework". Liquibase violates "failfast" because it fail after deployment, all dbschema-historic-informations are checked-out in one git/svn-revision, the :diff uses performance of the db, liquibase have an negative impact to appstart performance, liquibase has no gui, liquibase codebloat the app, liquibase's tables codebloat the db. – Grim Feb 14 '22 at 14:26
  • You can get fail fast as well here. What we do is we have integration tests where we start a postgres docker container and run the database migrations. So you immediately know whether your migrations still work with real data / the exact version of your database. The argument of performance of db you can neglect imho because you only do it during development a few times. And startup performance is also not an issue. Liquibase takes just a few seconds to check what migrations have to be executed if any (Usually you don't have new migrations). – Guillermo Feb 15 '22 at 12:33
  • @Guillermo You are integration testing having a copy of live database? Well I guess this works for small databases or high-performance docker environments. My pipeline live-deploys every successfull commit. After all - if you are happy this way I can accept this very well, friend. – Grim Feb 15 '22 at 18:08