Skip to content

Commit

Permalink
#2349 Generate explicit column names for audited properties
Browse files Browse the repository at this point in the history
This is necessary to overcome the inability to use underscore characters
in property names (due to specifics of mapping property names to
database column names).
  • Loading branch information
homedirectory committed Oct 30, 2024
1 parent 3518567 commit eb641ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.squareup.javapoet.AnnotationSpec;
import ua.com.fielden.platform.entity.AbstractEntity;
import ua.com.fielden.platform.entity.annotation.CompositeKeyMember;
import ua.com.fielden.platform.entity.annotation.MapTo;
import ua.com.fielden.platform.entity.annotation.Title;
import ua.com.fielden.platform.utils.Pair;

Expand Down Expand Up @@ -37,6 +38,12 @@ public static AnnotationSpec title(final CharSequence title) {
.build();
}

public static AnnotationSpec mapTo(final CharSequence value) {
return AnnotationSpec.builder(MapTo.class)
.addMember("value", "$S", value.toString())
.build();
}

private AnnotationSpecs() {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private void generateAuditEntity(
.map(PropertyMetadata::asPersistent).flatMap(Optional::stream)
.filter(AuditEntityGeneratorImpl::isAudited)
.map(pm -> propertyBuilder("a3t_" + pm.name(), pm.type().javaType())
.addAnnotation(javaPoet.getAnnotation(MapTo.class))
.addAnnotation(AnnotationSpecs.mapTo((A3T + "_" + pm.name()).toUpperCase()))
.addAnnotation(javaPoet.getAnnotation(Final.class))
.build())
.forEach(a3tBuilder::addProperty);
Expand Down

0 comments on commit eb641ad

Please sign in to comment.