generator-jhipster icon indicating copy to clipboard operation
generator-jhipster copied to clipboard

partialUpdate with reactive/webflux and elasticsearch does not update elasticsearch

Open MarcelRosenberger opened this issue 3 years ago • 6 comments

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)
[email protected] C:\Users\marcel\USB-Stick\workspace\test
`-- [email protected]

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.

  • [x] Checking this box is mandatory (this is just to show you read everything)

MarcelRosenberger avatar May 12 '21 20:05 MarcelRosenberger

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?

Tcharl avatar May 17 '21 21:05 Tcharl

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] avatar Jun 19 '21 00:06 github-actions[bot]

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] avatar Jul 21 '21 00:07 github-actions[bot]

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] avatar Sep 12 '21 00:09 github-actions[bot]

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] avatar Oct 17 '21 00:10 github-actions[bot]

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

github-actions[bot] avatar Aug 27 '24 00:08 github-actions[bot]