diff --git a/platform-dao/src/main/java/ua/com/fielden/platform/audit/AuditEntityGeneratorImpl.java b/platform-dao/src/main/java/ua/com/fielden/platform/audit/AuditEntityGeneratorImpl.java index ee31b0280b..bbefa7821f 100644 --- a/platform-dao/src/main/java/ua/com/fielden/platform/audit/AuditEntityGeneratorImpl.java +++ b/platform-dao/src/main/java/ua/com/fielden/platform/audit/AuditEntityGeneratorImpl.java @@ -140,7 +140,7 @@ private JavaFile generateAuditEntity( // By virtue of its name, this property's accessor and setter implement abstract methods in the base type final var auditedEntityTitle = TitlesDescsGetter.getEntityTitle(type); final var auditedEntityProp = propertyBuilder(AUDITED_ENTITY, type) - .addAnnotation(AnnotationSpecs.compositeKeyMember(AbstractAuditEntity.NEXT_COMPOSITE_KEY_MEMBER)) + .addAnnotation(AnnotationSpecs.compositeKeyMember(AbstractAuditEntity.AUDITED_ENTITY_KEY_MEMBER_ORDER)) .addAnnotation(javaPoet.getAnnotation(MapTo.class)) .addAnnotation(javaPoet.getAnnotation(Required.class)) .addAnnotation(javaPoet.getAnnotation(Final.class)) diff --git a/platform-pojo-bl/src/main/java/ua/com/fielden/platform/audit/AbstractAuditEntity.java b/platform-pojo-bl/src/main/java/ua/com/fielden/platform/audit/AbstractAuditEntity.java index 4f2e3e7e38..9fa6c63ef5 100644 --- a/platform-pojo-bl/src/main/java/ua/com/fielden/platform/audit/AbstractAuditEntity.java +++ b/platform-pojo-bl/src/main/java/ua/com/fielden/platform/audit/AbstractAuditEntity.java @@ -53,7 +53,12 @@ public abstract class AbstractAuditEntity> extends A */ public static final String CHANGED_PROPS = "changedProps"; - static final int NEXT_COMPOSITE_KEY_MEMBER = 2; + /** + * The composite key order that must be specified by the {@link #AUDITED_ENTITY} property. + */ + // Placing this property first ensures that its column comes first in the multi-column unique index that is always + // generated for composite keys, which improves performance because the first column in such an index is searchable. + static final int AUDITED_ENTITY_KEY_MEMBER_ORDER = 1; /** * Getter for property {@link #AUDITED_ENTITY}. @@ -73,7 +78,7 @@ public abstract class AbstractAuditEntity> extends A @IsProperty @MapTo @Title(value = "Audited entity version", desc = "Version of the entity for which this audit record was created.") - @CompositeKeyMember(1) + @CompositeKeyMember(2) private Long auditedVersion; @IsProperty