Closed pkernevez closed 2 years ago
Try using @MapsId
not @MapsId("ID")
.
Also, create an integration test and activate the hbm2ddl tool to let Hibernate create the schema for you. If Hibernate creates a separate FK, then the mapping was not working properly.
@pkernevez I also tested the @MapsId("ID")
mapping, and it's not taken into consideration by Hibernate, falling back to a separate FK.
The fact that Optimizer caught the issue is great because it shows it works. Just try it with @MapsId
and see for yourself.
I have the following message, I can't understand:
CRITICAL - OneToOneWithoutMapsIdEvent - The [fees] one-to-one association in the [InstrumentEntity] entity is using a separate Foreign Key to reference the parent record. Consider using @MapsId so that the identifier is shared with the parent row. For more info about this event, check out this User Guide link - https://vladmihalcea.com/hypersistence-optimizer/docs/user-guide/#OneToOneWithoutMapsIdEvent
I try to have a unidirectional one-to-one, and maps the parent ID as the child PK. This is my configuration:
And
Should I miss something or is it a false positive error ?