Skip to content

Conversation

@ghazwarhili
Copy link
Contributor

No description provided.

<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"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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"/>

Copy link
Contributor Author

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);
Copy link
Contributor Author

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:

  1. 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)
  2. DELETE FROM free_property WHERE id = ***;
  3. 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

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
72.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants