jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

Reactive app generation is missing to generate the mapping to DTO in the service class #21735

Closed anothergoodguy closed 1 year ago

anothergoodguy commented 1 year ago
Overview of the issue

I am exploring Jhipster with spring-boot 3 of the main branch and generated a sample project with one of the JDL samples. After the generation with the project I see the service classes have mapping errors.

I know that main branch is under active development; however wanted to share my observation so that it can help the dev team.

findByCriteria methods in service classes are generated like the below example:

    @Transactional(readOnly = true)
    public Flux<AddressDTO> findByCriteria(AddressCriteria criteria, Pageable pageable) {
        log.debug("Request to get all Addresses by Criteria");
        return addressRepository.findByCriteria(criteria, pageable);
    }
Motivation for or Use Case

It's a compilation error with type mapping

Reproduce the error

I tried re-generating and can see the issue is consistent

Suggest a Fix

The fix should be to map it before returning like:

return addressRepository.findByCriteria(criteria, pageable).map(addressMapper::toDto);

JHipster Version(s)

It's on the main branch, so I think it's 8.0.0 PreAlpha

JHipster configuration

Attaching the configuration from the result of jhipster info jhipster info result.txt

anothergoodguy commented 1 year ago

I am adding One more observation on the same generated app, please advise if it needs a separate issue I can open one more:

Issue Details: in the same generated application with above mentioned configuration, UserRepository is generated as ID type Long. even though the configuration has "pkType": "UUID",.

the class declaration statement is generated as : public interface UserRepository extends R2dbcRepository<User, Long>, UserRepositoryInternal {

It should have generated as: public interface UserRepository extends R2dbcRepository<User, UUID>, UserRepositoryInternal {

This in-turn causes a compilation error in UserService class's updateUser method, due to the type mapping...

deepu105 commented 1 year ago

@anothergoodguy can you do a PR

anothergoodguy commented 1 year ago

@deepu105 I recently started to come back on to active development after many years. Even when I was a developer, I mostly worked on Java.

Not able to setup the dev env, on my mac, but I am not successful. I wanted to try learning it by creating my own simple blueprints, but not successful there either.

Can I test and report the issues till I get my self proficient on JHipster?

Thanks...

deepu105 commented 1 year ago

@anothergoodguy no worries all kinds of contributions including feedback and issue reports are appreciated 🙏

deepu105 commented 1 year ago

@dinu0000 can you take a look at this?

dinu0000 commented 1 year ago

@dinu0000 can you take a look at this?

Yeah sure. Will look into this.

dinu0000 commented 1 year ago

just realized that this issue report has two seperate issues and I started working on the UUID part. @anothergoodguy can you provide the .yo-rc.json for the first issue regarding the DTO mapping?

anothergoodguy commented 1 year ago

I have attached both jhipster.info.result and .yo-rc.json

please let me know if you want me to publish the generated app to a temp git repo...

deepu105 commented 1 year ago

Bumping bounty since reactive templates are PITA and this will be a lot of testing work to get right

dinu0000 commented 1 year ago

Bounty Claimed
https://opencollective.com/generator-jhipster/expenses/158050

DanielFran commented 1 year ago

@dinu0000 approved