-
Notifications
You must be signed in to change notification settings - Fork 0
fix addForeignKeyConstraint #716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| <addForeignKeyConstraint baseColumnNames="operational_limits_groups_id" baseTableName="line_modification_operational_limits_groups" constraintName="operational_limits_groups_line_modification_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="uuid" referencedTableName="operational_limits_group_modification" validate="true"/> | ||
| </changeSet> | ||
| <changeSet author="rehiligha (generated)" id="1761058240544-43"> | ||
| <addForeignKeyConstraint baseColumnNames="operational_limits_groups_id" baseTableName="two_windings_transformer_modification_operational_limits_groups" constraintName="operational_limits_groups_twt_modification_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="uuid" referencedTableName="operational_limits_group_modification" validate="true"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <addForeignKeyConstraint baseColumnNames="operational_limits_groups_id" baseTableName="two_windings_transformer_modification_operational_limits_groups" constraintName="operational_limits_groups_twt_modification_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="uuid" referencedTableName="operational_limits_group_modification" validate="true"/> | |
| <addForeignKeyConstraint baseColumnNames="operational_limits_groups_id" baseTableName="two_windings_transformer_modification_operational_limits_groups" constraintName="operational_limits_groups_2wt_modification_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="uuid" referencedTableName="operational_limits_group_modification" validate="true"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| SQLStatementCountValidator.reset(); | ||
| networkModificationRepository.deleteModificationGroup(TEST_GROUP_ID, true); | ||
| assertRequestsCount(5, 0, 2, 4); | ||
| assertRequestsCount(5, 0, 1, 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@onetomany
@joincolumn(name = "equipment_modification_id")
The OneToMany owns the FK since it's declared on the parent side
On delete:
- UPDATE free_property SET equipment_modification_id = NULL WHERE equipment_modification_id = :id;
(because the FK is managed by the parent, so we must break it before the delete) - DELETE FROM free_property WHERE id = ***;
- DELETE FROM modification WHERE id = ***;
=> Results in 2 UPDATEs (UPDATE generated before the DELETE)
With:
FreePropertyEntity:
@manytoone
@joincolumn(name = "equipment_modification_id")
private ModificationEntity modification;
EquipmentModificationEntity:
@onetomany(mappedBy = "modification")
private List properties;
=> The ManyToOne owns the FK
On delete:
DELETE FROM free_property WHERE equipment_modification_id = :id
(the FK is managed by the child, so no need to set it to NULL)
Since we have @OrderColumn(name = "insert_position") an UPDATE is generated to update and reindex the list before DELETE
|


No description provided.