FINERACT-2766: Tax Component - User should be able to edit a tax component - #6287
Open
rymghosn wants to merge 1 commit into
Open
Conversation
…onship bidirectional The taxComponentHistories collection was mapped as a unidirectional OneToMany with a NOT NULL JoinColumn and no owning side declared on the child, which risks flush-ordering issues against the foreign key when a new history row is added to an already-persisted TaxComponent (exactly what happens when a tax component's percentage or start date is edited). Add a ManyToOne back-reference on TaxComponentHistory and let it own the foreign key via mappedBy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TaxComponent.taxComponentHistories was mapped as a unidirectional @onetomany with a @joincolumn(nullable = false) and no owning side (mappedBy)
declared on the child entity. This is a problematic pattern for a foreign-key-based one-to-many: since the parent's collection — not the child —
is left managing the relationship, adding a new TaxComponentHistory row to an already-persisted TaxComponent risks a flush-ordering issue against
the NOT NULL foreign key column. This is exactly what happens whenever a tax component's percentage or start date is edited
(TaxComponent.update() adds a new history entry to the collection).
This PR makes the relationship properly bidirectional:
TaxComponent.update().
No API/behavior changes — this is purely a persistence-mapping correctness fix, functionally equivalent for read paths but avoids the
flush-ordering hazard on write.