Skip to content

Conversation

@dfcoffin
Copy link
Contributor

@dfcoffin dfcoffin commented Jan 8, 2026

Summary

This PR implements Phase 3 of ESPI 4.0 schema compliance, updating IntervalReading to match the ESPI 4.0 XSD specification (espi.xsd:1016-1061).

Key Changes

IntervalReadingEntity:

  • Changed ID from UUID to Long (48+ bits) per Object pattern
  • IntervalReading extends Object, not IdentifiedObject
  • Reordered fields to match XSD sequence: costreadingQualitiestimePeriodvalueconsumptionTiertoucpp
  • Updated @GeneratedValue to use IDENTITY strategy
  • Removed UUID-related imports

IntervalReadingDto:

  • Removed currency field (not in ESPI 4.0 XSD)
  • Reordered record components to match XSD sequence
  • Updated @XmlType propOrder for correct XML marshalling
  • Updated all convenience constructors

IntervalReadingMapper:

  • Simplified mappings (MapStruct handles field mapping by name)
  • Removed explicit field mappings
  • Kept only necessary ignore mappings (id, intervalBlock)

Flyway Migrations:

  • Moved meter_readings, interval_blocks, and interval_readings tables from V3 to V2 vendor-specific files
  • Rationale: IntervalReading requires vendor-specific auto-increment syntax:
    • MySQL/H2: BIGINT AUTO_INCREMENT
    • PostgreSQL: BIGSERIAL
  • Updated V3 reading_qualities.interval_reading_id from CHAR(36) to BIGINT to match new FK type
  • Added clear documentation in V3 explaining table relocation

Test Updates:

  • Fixed DtoExportServiceImplTest to use new constructor signature
  • All 550 tests passing including integration tests

Migration Strategy

  • V1: Base vendor-neutral tables
  • V2: Vendor-specific tables (now includes meter_readings, interval_blocks, interval_readings with correct auto-increment syntax)
  • V3: Additional tables that depend on V1 and V2

Test Plan

✅ All 550 unit and integration tests passing

  • PostgreSQL TestContainer integration tests: ✅
  • MySQL TestContainer integration tests: ✅
  • H2 in-memory integration tests: ✅
  • Complex relationship integration tests: ✅

Technical Details

XSD Reference: espi.xsd:1016-1061

<xs:complexType name="IntervalReading">
  <xs:complexContent>
    <xs:extension base="Object">
      <xs:sequence>
        <xs:element name="cost" type="Int48" minOccurs="0"/>
        <xs:element name="ReadingQuality" type="ReadingQuality" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="timePeriod" type="DateTimeInterval" minOccurs="0"/>
        <xs:element name="value" type="Int48" minOccurs="0"/>
        <xs:element name="consumptionTier" type="Int16" minOccurs="0" maxOccurs="1"/>
        <xs:element name="tou" type="Int16" minOccurs="0" maxOccurs="1"/>
        <xs:element name="cpp" type="Int16" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

Files Changed:

  • IntervalReadingEntity.java - Changed ID type, reordered fields
  • IntervalReadingDto.java - Removed currency, reordered fields
  • IntervalReadingMapper.java - Simplified mappings
  • V3__Create_additiional_Base_Tables.sql - Relocated tables, fixed FK type
  • V2__MySQL_Specific_Tables.sql - Added meter_readings, interval_blocks, interval_readings
  • V2__PostgreSQL_Specific_Tables.sql - Added meter_readings, interval_blocks, interval_readings
  • V2__H2_Specific_Tables.sql - Added meter_readings, interval_blocks, interval_readings
  • DtoExportServiceImplTest.java - Fixed test constructor calls

Related

🤖 Generated with Claude Code

This commit implements Phase 3 of ESPI 4.0 schema compliance, updating
IntervalReading to match the ESPI 4.0 XSD specification (espi.xsd:1016).

Key Changes:

IntervalReadingEntity:
- Changed ID from UUID to Long (48+ bits) per Object pattern
- IntervalReading extends Object, not IdentifiedObject
- Reordered fields to match XSD sequence: cost → readingQualities →
  timePeriod → value → consumptionTier → tou → cpp
- Updated @GeneratedValue to use IDENTITY strategy
- Removed UUID-related imports

IntervalReadingDto:
- Removed currency field (not in ESPI 4.0 XSD)
- Reordered record components to match XSD sequence
- Updated @XmlType propOrder for correct XML marshalling
- Updated all convenience constructors

IntervalReadingMapper:
- Simplified mappings (MapStruct handles by name)
- Removed explicit field mappings
- Kept only necessary ignore mappings (id, intervalBlock)

Flyway Migrations:
- Moved meter_readings, interval_blocks, and interval_readings tables
  from V3 to V2 vendor-specific files
- Rationale: IntervalReading requires vendor-specific auto-increment
  syntax (BIGINT AUTO_INCREMENT for MySQL/H2, BIGSERIAL for PostgreSQL)
- Updated V3 reading_qualities.interval_reading_id from CHAR(36) to BIGINT
- Added clear documentation in V3 explaining table relocation

Test Updates:
- Fixed DtoExportServiceImplTest to use new constructor signature
- All 550 tests passing including integration tests

Migration Strategy:
- V1: Base vendor-neutral tables
- V2: Vendor-specific tables (now includes meter_readings, interval_blocks,
  interval_readings with correct auto-increment syntax)
- V3: Additional tables that depend on V1 and V2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@dfcoffin dfcoffin merged commit b9127e2 into main Jan 8, 2026
5 checks passed
@dfcoffin dfcoffin deleted the feature/schema-compliance-phase-3-interval-reading branch January 8, 2026 14:21
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.

2 participants