When using nested embeddable entities, the @AttributeOverrides are not used for the attributes in the nested entities. This results in overridden columns in DB when more than one nested embeddable entity of the same type is used.
Test project:
nested_embeddable.zip (105.7 KB)
The resulting Liquibase is:
<createTable tableName="TEST_ENTITY">
<column name="EMBEDDED_ATTRIBUTE1_FIRST_LEVEL_ATTRIBUTE" type="VARCHAR(255)"/>
<column name="FIRST_LEVEL_EMBEDDED_ATTRIBUTE_SECOND_LEVEL_ATTRIBUTE" type="VARCHAR(255)"/>
<column name="EMBEDDED_ATTRIBUTE2_FIRST_LEVEL_ATTRIBUTE" type="VARCHAR(255)"/>
</createTable>
Expected would be (I added prefixes for all nested levels):
<createTable tableName="TEST_ENTITY">
<column name="EMBEDDED_ATTRIBUTE1_FIRST_LEVEL_ATTRIBUTE" type="VARCHAR(255)"/>
<column name="EMBEDDED_ATTRIBUTE1_FIRST_LEVEL_EMBEDDED_ATTRIBUTE_SECOND_LEVEL_ATTRIBUTE" type="VARCHAR(255)"/>
<column name="EMBEDDED_ATTRIBUTE2_FIRST_LEVEL_ATTRIBUTE" type="VARCHAR(255)"/>
<column name="EMBEDDED_ATTRIBUTE2_FIRST_LEVEL_EMBEDDED_ATTRIBUTE_SECOND_LEVEL_ATTRIBUTE" type="VARCHAR(255)"/>
</createTable>
EMBEDDED_ATTRIBUTE1_
and EMBEDDED_ATTRIBUTE2_
were added to the 3rd and 5th column. The 5th column is new.
Even if I manually add @AttributeOverride for the 2nd level (see below) it doesn’t produce the wished-for Liquibase:
@EmbeddedParameters(nullAllowed = false)
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "firstLevelAttribute", column = @Column(name = "EMBEDDED_ATTRIBUTE1_FIRST_LEVEL_ATTRIBUTE")),
// This is the missing @AttributeOverride for the 2nd level attribute.
@AttributeOverride(name = "secondLevelAttribute", column = @Column(name = "EMBEDDED_ATTRIBUTE1_FIRST_LEVEL_EMBEDDED_ATTRIBUTE_SECOND_LEVEL_ATTRIBUTE"))
})
private FirstLevelEmbeddable embeddedAttribute1;
@EmbeddedParameters(nullAllowed = false)
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "firstLevelAttribute", column = @Column(name = "EMBEDDED_ATTRIBUTE2_FIRST_LEVEL_ATTRIBUTE")),
// This is the missing @AttributeOverride for the 2nd level attribute.
@AttributeOverride(name = "secondLevelAttribute", column = @Column(name = "EMBEDDED_ATTRIBUTE2_FIRST_LEVEL_EMBEDDED_ATTRIBUTE_SECOND_LEVEL_ATTRIBUTE"))
})
private FirstLevelEmbeddable embeddedAttribute2;
@AssociationOverrides should also add prefixes for all nested levels.
Is it possible to support using @AttributeOverride and @AssociationOverride for nested embedded entities if they are present as in the code above (see both @AttributeOverride(name = "secondLevelAttribute"
)?
Jmix version: 2.5.0
Jmix Studio Plugin Version: 2.5.0-243
IntelliJ version: IntelliJ IDEA 2024.3.4.1 (Community Edition)