JHIPSTER CONF : Custom and Generated Code Side by Side by Antonio Goncalves

Ippon Technologies · 5K views · 2018 · 30:15

Open on YouTube

Software architecture & designWeb developmenttalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when someone asks how to customize JHipster entities or repositories without losing changes each time the project is regenerated.

Recommended by 4 people across 5 different months, 2018 to 2023.

What it is

A 30-minute conference talk from JHipster Conf 2018 by Antonio Goncalves on keeping hand-written code alongside code generated by JHipster. It covers the 'side-by-side' approach of extending generated classes in backend and frontend so that regenerating entities does not overwrite custom work.

What people said

Strong rec Gaël Marziou · 2018-08 · Stack Overflow · on “Composition relations with jHipster”

Custom code is the way to go though there are few tricks that can help you: Using DTOs so you can aggregate entities in service layer Extending generated classes both in backend and frontend so that you don't change generated code, see excellent talk [this video] , slides [LINK] and code samples [LINK] from Antonio Goncalves

Recommends Alexandre GC · 2018-07 · Stack Overflow · on “How to prevent a custom repository method from being deleted when regenerating a jHipster entity”

I don't think you can. Every time I'm doing any kind of generation with JHipster on an existing project, I push everything on git to be sure to have a backup. After that, I make sure to take a good look a diffs when resolving conflicts in the interactive tool in JHipster. That way, you can choose to not overwrite you repository. It's a bit tedious but at the end, it works. You can also check that video [this video] that explains how to efficiently work with JHipster without risking overwriting custom code.

Recommends vicpermir · 2020-02 · Stack Overflow · on “Preventing JHipster import-jdl from overwriting changes when updating entities”

I faced this problem in one of my projects and I'm afraid there is no easy way to tell JHipster not to overwrite your changes. The good news is you have two ways of mitigating this and both will make your life much easier. Update your entities in a separate branch The idea is to update your entities (execute the import-jdl command) in a different branch and then, once the whole process is finished merge the changes back to master. This requires no extra changes to your code. The problem I had with this approach is that sometimes the merges were not trivial and I still had to go through a lot of code just to be sure that everything was still in place and working properly. Do not change the ge

Recommends Gaël Marziou · 2020-04 · Stack Overflow · on “How to update entities in JHipster without losing previous logic work?”

In JHipster community, this is known as side-by-side approach. Have you seen these presentations? [LINK] and [this video]

Recommends jelharou · 2023-09 · Stack Overflow · on “What is the best practice of JHispter consumization?”

Not sure who closed it but this must have come up a lot in the past... Did you look at the talks on Youtube? Here are the ones I had in mind. They may be old but give you some perspective: * [this video] * [LINK]

Cites Gaël Marziou · 2018-08 · Stack Overflow · on “Jhipster override entity (keep existant + add behaviour)”

Your approach looks like the side-by-side approach described here: [this video] I often found that the generated REST API is only useful for managing data in a backoffice and I usually write a complete separate API with different endpoints, authorizations and DTOs that is consumed by mobile or end-users. So I don't see much value in overriding REST controllers, after all they are supposed to be quite thin with as little business logic as possible. You must also consider how long you want to keep this compatibility with generated code. As your app grows in complexity you might want to refactor your code and organize it around feature packages rather than by technical packages (repository, rest con

Cites Gaël Marziou · 2020-06 · Stack Overflow · on “Splitting JDL file to extend model step by step”

User is never generated because it's not a JHipster entity, same for Authorities and all other predefined classes that are mapped to tables from initial database schema. JDL does not support what you want. If your goal is to preserve your manual changes from being overwritten by re-generation, you should have a look at what the community calls side-by-side approach: JHipster conf 2019: [LINK] JHipster conf 2018: [this video] Alternatively, you can rely on git by always generating on a branch and merging on master with git merging strategy options.