<!--
- Please follow the issue template below for bug reports.
- If you have a… support request rather than a bug, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/jhipster) with the JHipster tag.
- For bug reports it is mandatory to run the command `jhipster info` in your project's root folder, and paste the result here.
- Tickets opened without any of these pieces of information will be **closed** without any explanation.
-->
##### **Overview of the issue**
I did a PR for adding `@MapsId` support in #8685 . The related raised issue is #7060.
However, while writing automated tests #9094 I come to know that if you update the child entity with a new parent then this updated new parent will be used for current transaction.
However, in next request, next time if you load the child then it will refer to its parent which was originally mapped.
##### **Motivation for or Use Case**
Child should always refers to its correct parent in any case.
##### **Reproduce the error**
1. Generate a new app with current master
1. Add following entity.json inside `.jhipster` and regenerate entity with `jhipster entity Bar`
```
{
"fluentMethods": true,
"clientRootFolder": "",
"relationships": [
{
"relationshipName": "user",
"otherEntityName": "user",
"relationshipType": "one-to-one",
"otherEntityField": "login",
"ownerSide": true,
"useJPADerivedIdentifier": true,
"otherEntityRelationshipName": "bar"
}
],
"fields": [
{
"fieldName": "ddd",
"fieldType": "String"
}
],
"changelogDate": "20181231104458",
"dto": "no",
"searchEngine": false,
"service": "serviceImpl",
"entityTableName": "bar",
"databaseType": "sql",
"jpaMetamodelFiltering": false,
"pagination": "no"
}
```
1. Launch the application
1. Create a new Bar using browser and set user `user`
1. Open devtool and go to network tab
1. Update the Bar to set `admin`
1. Check `PUT` method response body in devtool and u can see the returned bar contains `admin`
1. But any new next request such as listing/view/edit will load the correct `user`
##### **Related issues**
#7060
#8685
#9094 WIP
##### **Suggest a Fix**
-
<!-- If you can't fix the bug yourself, perhaps you can point to what might be
causing the problem (line of code or commit) -->
##### **JHipster Version(s)**
- master branch
<!--
Which version of JHipster are you using, is it a regression?
-->
##### **JHipster Version(s)**
```
mo@0.0.0 /Users/sierra/github/mp
└── (empty)
```
##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
<details>
<summary>.yo-rc.json file</summary>
<pre>
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp"
},
"jhipsterVersion": "5.7.2",
"applicationType": "monolith",
"baseName": "mo",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "no",
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
"clientFramework": "angularX",
"useSass": false,
"clientPackageManager": "npm",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": false,
"enableHibernateCache": false,
"otherModules": []
}
}
</pre>
</details>
##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**
<details>
<summary>JDL entity definitions</summary>
<pre>
entity Bar {
ddd String
}
relationship OneToOne {
Bar{user(login)} to User
}
service Bar with serviceImpl
</pre>
</details>
##### **Environment and Tools**
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
git version 2.17.2 (Apple Git-113)
node: v10.14.2
npm: 6.4.1
yeoman: 2.0.5
Docker version 18.09.0, build 4d60db4
docker-compose version 1.23.2, build 1110ad01
- [ ] Checking this box is mandatory (this is just to show you read everything)
<!-- Love JHipster? Please consider supporting our collective:
👉 https://opencollective.com/generator-jhipster/donate -->