Is it possible to re-generate a jhipster jdl file from an existing jhipster project? - jhipster

I'm new to jhipster, but I recently started working on a jhipster-generated project where the previous person added changes to the entity manually rather than using jhipster. I'm wondering if it's possible to update the jdl and json files to reflect the current entity.

Related

jhipster - possible to iterate on database schema using JDL Studio?

I'm new to jhipster, and have created a JDL file for Entities in my service using JDL Studio.
My goal is to keep iterating on my DB design, using JDL Studio, and then run the service so I can see the Entity screens that jhipster has created. How should I do this?
I have reviewed the docs on database updates, but I find it doesn't lay out this common development task clearly - wanting to iterate on a DB design. I see suggestions fo using jhipster entity ... but does that mean JDL Studio can only be used at the start of development?
My current process I'm hoping will work in some fashion is this:
Make changes to my entities in JDL Studio
Download changes to entities.jdl
run jhipster import-jdl entities.jdl
Tell it to overwrite everything - I have no customizations to the code yet in anyway.
Try and run the service using ./mvnw
I currently have very little code that is custom so far, and what I have is committed to git, so I can diff/revert changes if need be.
The problem is that I see to get conflicts, or the app breaks and won't compile, around things that seem related to the entities not being updated correctly. I'm perfectly fine with overwriting everything to just get the updated entities, and front end files
I've tried removing node_modules, target, and .jhipster/* files to see if I could cleanly recreate the entities, but it still has conflicts.
Note I'm only using H2 at this point, and don't plan on using liquibase/a real db until I actually release something, so probably months from now. Thanks!
As suggested in the question comments, the basic process is as I listed in my question. I think there were 2 things that solved my problem
completely removing the src folder, and allowing it to be regenerated
supplying both my JDL files at once on the command line.
I have 2 JDL files, one for entities, and one for relationships, which I broke out separately while trying to figure out how to best do these updates. I was running them separately as well, which worked fine for the entities JDL file, but wouldn't for the relationships one, as it needed the entities too.
So my solution seems to have been the following:
cd my_project
rm -fr src target
jhipster import-jdl entities.jdl relationships.jdl
If I found my entities weren't being regenerated, I also deleted the .jhipster folder, but not sure if this is required or not
rm .jhipster/*
Once again - I am completely new to jhipster, so there may be better processes, but this seems to have resolved my issues !

Entity for a view Jhipster

I am new in jhipster and I would like to know If I can create an entity for a view like the table with jhipster command ? And how to do it ?
I used jhipster entity command but I am not sure this is the right way to do it
JHipster does not support SQL views in Liquibase but JDL lets you flag an entity as read-only which will prevent generating code for creating or updating an entity.
You can then manually adapt generated code to replace table by view, it should be limited to Liquibase migration file.
See official JDL doc for examples: https://www.jhipster.tech/jdl/options
jhipster entity command also asks you whether new entity should be read-only.

JHipster Import-jdl Entity generator master.xml and CacheConfiguration not updated

I generated a microservice application using JHipster then I generated a lot of entities by using the JHipster "import-jdl" command.
But recently I noticed that after running import-jdl command, newly created changelog files not being reflected on master.xml Liquibase file and CacheConfiguration class not being updated with a newly created entity.
I think that behaviour happened because JHipster skips the files overriding. But it should ask me before generation if I want to force or skip the file overriding.
I know the reason for this issue. by mistake, I remove the notes added by JHipster when the application was created
master.xml
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
CacheConfiguration
// jhipster-needle-ehcache-add-entry

Update ddl from existing entity Jhipster

I started to use Jhipster. I have existing entity in
com.company.project_name.module_name.MyCastomEntity
which I created manually.
I don't want to use jhipster command
yo jhipster:entity MyCustomEntity
How to update ddl using existing entity after manual change(entity creation/updating/deletion)?
Configure database properties in your pom.xml and use ./mvnw liquibase:diff to generate a Liquibase migration file that you will store in src/main/resources/config/liquibase/changelog directory and refer to it from src/main/resources/config/liquibase/master.xml
This is documented on JHipster web site

Generate entity related files based on current entity java class with jhipster

Because of some reason, I want to use my current java entity classes to generate all entity related files, which are generated with yo jhipster:entity book. I need the liqibase configuration files, repository files, rest resources, and the sample files of html and js files.
So is there any way I can do that?
I don't think there's a way to do that at the moment. But with JHipster 2 you could manually create a .jhipster/{entityname}.json file based on your class, and that would generate those files (and also recreate the class object) you're looking for.

Resources