Add Line segments infos into database for line creation#787
Add Line segments infos into database for line creation#787
Conversation
📝 WalkthroughWalkthroughAdds persistent line-segment support: new Changes
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java`:
- Around line 44-49: LineCreationEntity currently maps the
List<LineSegmentEntity> lineSegments without preserving order; update the
mapping on lineSegments to add an `@OrderColumn` (e.g., `@OrderColumn`(name =
"line_segments_order") or similar) so the list index is persisted and round-trip
order is stable, and explicitly set the join table name in the `@JoinTable` (e.g.,
name = "line_creation_line_segments") rather than relying on Hibernate defaults
so Liquibase schema matches; keep the existing joinColumns, inverseJoinColumns
and uniqueConstraints but move them into the explicitly named `@JoinTable` and
ensure the OrderColumn column name does not conflict with existing constraints.
In
`@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java`:
- Around line 66-75: fromLineSegmentsEntity currently dereferences its input
list and will NPE if lineSegmentEntities is null; make it null-safe by returning
Collections.emptyList() (or new ArrayList<>()) when lineSegmentEntities is null,
otherwise map each LineSegmentEntity to a LineSegmentInfos as it does now,
updating the method body in fromLineSegmentsEntity to check for null before
iterating; this mirrors the null-safety in toLineSegmentEntities and avoids
breaking LineCreationEntity.toLineCreationInfosBuilder.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e37c68b4-5f4e-4f48-8d9e-95d0b0d7429d
📒 Files selected for processing (4)
pom.xmlsrc/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.javasrc/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.javasrc/main/resources/db/changelog/db.changelog-master.yaml
...n/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java
Show resolved
Hide resolved
...in/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java
Show resolved
Hide resolved
Signed-off-by: basseche <bassel.el-cheikh_externe@rte-france.com>
c09f515 to
5ff3748
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java (1)
44-49:⚠️ Potential issue | 🟠 MajorPersist
lineSegmentsorder.This is still mapped as an ordered
List, but the association does not store any index. After a save/reload cycle, segment order is unspecified and the reconstructedLineCreationInfoscan change. Add an@OrderColumnhere and the matching column inline_creation_line_segments.Suggested change
`@OneToMany`(cascade = CascadeType.ALL, orphanRemoval = true) + `@OrderColumn`(name = "segment_index") `@JoinTable`( joinColumns = `@JoinColumn`(name = "line_id"), foreignKey = `@ForeignKey`(name = "line_id_fk"), inverseJoinColumns = `@JoinColumn`(name = "line_segments_id"), inverseForeignKey = `@ForeignKey`(name = "line_segments_id_fk"), uniqueConstraints = `@UniqueConstraint`(name = "line_creation_line_segments_uk", columnNames = {"line_segments_id"})) private List<LineSegmentEntity> lineSegments;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java` around lines 44 - 49, The lineSegments List in LineCreationEntity is not persisted with an order index; add `@OrderColumn` to the lineSegments field (e.g., `@OrderColumn`(name = "segment_order")) and update the join table definition for line_creation_line_segments to include the matching index column (segment_order) so JPA will persist and restore the List element order; ensure the column is included in the JoinTable DDL/migration and name matches the `@OrderColumn` value.
🧹 Nitpick comments (1)
src/main/resources/db/changelog/changesets/changelog_20260324T101024Z.xml (1)
4-11: Indexline_creation_line_segments.line_id.
LineCreationEntity.lineSegmentswill be read and cleaned up throughline_id, but the schema only gets an index online_segments_idvia the unique constraint. Add a parent-side index here to avoid full scans and expensive FK checks once this join table grows.Suggested change
<changeSet author="elcheikhbas (generated)" id="1774347058503-15"> <createTable tableName="line_creation_line_segments"> <column name="line_id" type="UUID"> <constraints nullable="false"/> </column> <column name="line_segments_id" type="UUID"> <constraints nullable="false"/> </column> </createTable> + <createIndex indexName="line_creation_line_segments_line_id_idx" + tableName="line_creation_line_segments"> + <column name="line_id"/> + </createIndex> </changeSet>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/resources/db/changelog/changesets/changelog_20260324T101024Z.xml` around lines 4 - 11, Add a non-unique index on the parent column to avoid full scans: modify the changeset that creates the join table line_creation_line_segments to add an index for column "line_id" (in addition to the existing unique constraint on "line_segments_id"); update the XML to include an <createIndex> (or equivalent index element) targeting tableName="line_creation_line_segments" and column name="line_id" so lookups from LineCreationEntity.lineSegments use the indexed parent key.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java`:
- Around line 44-49: The lineSegments List in LineCreationEntity is not
persisted with an order index; add `@OrderColumn` to the lineSegments field (e.g.,
`@OrderColumn`(name = "segment_order")) and update the join table definition for
line_creation_line_segments to include the matching index column (segment_order)
so JPA will persist and restore the List element order; ensure the column is
included in the JoinTable DDL/migration and name matches the `@OrderColumn` value.
---
Nitpick comments:
In `@src/main/resources/db/changelog/changesets/changelog_20260324T101024Z.xml`:
- Around line 4-11: Add a non-unique index on the parent column to avoid full
scans: modify the changeset that creates the join table
line_creation_line_segments to add an index for column "line_id" (in addition to
the existing unique constraint on "line_segments_id"); update the XML to include
an <createIndex> (or equivalent index element) targeting
tableName="line_creation_line_segments" and column name="line_id" so lookups
from LineCreationEntity.lineSegments use the indexed parent key.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 15fbc59c-757c-495e-972a-c80ba2170599
📒 Files selected for processing (5)
pom.xmlsrc/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.javasrc/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.javasrc/main/resources/db/changelog/changesets/changelog_20260324T101024Z.xmlsrc/main/resources/db/changelog/db.changelog-master.yaml
✅ Files skipped from review due to trivial changes (2)
- src/main/resources/db/changelog/db.changelog-master.yaml
- pom.xml
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java
flomillot
left a comment
There was a problem hiding this comment.
No tests ? DTO conversion etc
PR Summary
Add Line segments entity table related to line creation