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.53k stars 4.02k forks source link

partialUpdate with reactive/webflux and elasticsearch does not update elasticsearch #14964

Closed MarcelRosenberger closed 1 month ago

MarcelRosenberger commented 3 years ago
Overview of the issue

When using the options webflux/reactive and elasticsearch a PATCH-request will not update the entity in elasticsearch. The reason is that inside the partialUpdate method of the service class the entitySearchRepository.save method in the reactor chain is not subscribed.

Reproduce the error
public Mono<BookDTO> partialUpdate(BookDTO bookDTO) {
        log.debug("Request to partially update Book : {}", bookDTO);

        return bookRepository
            .findById(bookDTO.getId())
            .map(
                existingBook -> {
                    bookMapper.partialUpdate(existingBook, bookDTO);
                    return existingBook;
                }
            )
            .flatMap(bookRepository::save)
            .flatMap(
                savedBook -> {
                    bookSearchRepository.save(savedBook); /* THE IMPLEMENTATION IS NOT EXECUTED */

                    return Mono.just(savedBook);
                }
            )
            .map(bookMapper::toDto);
    }
Suggest a Fix
[...]
.flatMap(bookRepository::save)
.flatMap(bookSearchRepository::save)
.map(bookMapper::toDto);
JHipster Version(s)

7.0.1

JHipster configuration

INFO! Using JHipster version installed globally Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
test@0.0.0 C:\Users\marcel\USB-Stick\workspace\test
`-- generator-jhipster@7.0.1
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "blueprints": [],
    "otherModules": [],
    "applicationType": "microservice",
    "baseName": "test",
    "jhipsterVersion": "7.0.1",
    "skipClient": true,
    "skipUserManagement": true,
    "skipServer": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": [],
    "pages": [],
    "creationTimestamp": 1620847780342,
    "serviceDiscoveryType": "eureka",
    "reactive": true,
    "authenticationType": "jwt",
    "packageName": "com.mycompany.myapp",
    "serverPort": "8081",
    "cacheProvider": "no",
    "enableHibernateCache": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "prodDatabaseType": "postgresql",
    "buildTool": "gradle",
    "serverSideOptions": ["searchEngine:elasticsearch"],
    "websocket": false,
    "searchEngine": "elasticsearch",
    "messageBroker": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "nativeLanguage": "en",
    "packageFolder": "com/mycompany/myapp",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en", "de"],
    "lastLiquibaseTimestamp": 1620848222000,
    "entities": ["Book", "Author"]
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Book {
  title String required
  subtitle String
  isbn Long required unique
}
entity Author {
  firstname String
  lastname String
}
relationship ManyToOne {
  Author{book required} to Book
}

dto Book, Author with mapstruct
service Book, Author with serviceClass
microservice Book, Author with test
clientRootFolder Book, Author with test

Environment and Tools

git version 2.19.1.windows.1

node: v14.16.0

npm: 6.14.11

Docker version 20.10.5, build 55c4c88

docker-compose version 1.29.0, build 07737305

No change to package.json was detected. No package manager install will be executed. Congratulations, JHipster execution is complete! Sponsored with ❤️ by @oktadev.

Tcharl commented 3 years ago

you're right: the bookSearchRepository. save is not executed...

From what I remember, object saved from elasticsearch are different than ones from database: we do not save *ToMany nested elements in ES. So retuning the element saved from ES could have side effect: WDYT?

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted. We are accepting PRs :smiley:. Comment or this will be closed in 7 days

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted. We are accepting PRs :smiley:. Comment or this will be closed in 7 days

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted. We are accepting PRs :smiley:. Comment or this will be closed in 7 days

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted. We are accepting PRs :smiley:. Comment or this will be closed in 7 days

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for too long without any activity. Due to the moving nature of jhipster generated application, bugs can become invalid. If this issue still applies please comment otherwise it will be closed in 7 days