Annotation Type DtoIgnore
null, or List.of() for a java.util.List-typed property) rather than
populated from the source entity, in every mapping (base and every named variant alike).
Used with generated entity-to-DTO graph mapping (see query.mapTo(SomeDto.class)) for a
DTO property that can never be derived from the registered source entity at all - typically
because it's populated later, by application code, from an entirely different source (e.g. a
separate ad-hoc query, a service call, or a value only known post-construction) rather than a
plain getter or entity relation:
@DtoMixin(Fleet.class)
interface FleetMixin {
@DtoIgnore
List<OrgMachineSummary> assignedMachines();
@DtoIgnore
List<DriverSummary> assignedDrivers();
}
When the target uses builder-based construction (see @DtoMapping#builder()), the
generated mapper additionally exposes a mapToBuilder(source) method returning the
target's builder one step before its final build() call, so callers can set an
@DtoIgnore property's real value (typically sourced from another query/service call
entirely outside this mapper's own fetch graph) before finishing construction:
FleetBuilder b = mapper.mapToBuilder(cFleet);
if (withMachines) b.assignedMachines(loadAssignedMachines(cFleet));
Fleet fleet = b.build();
Distinct from a named @DtoMapping(name = ..., exclude = ...) variant, which
conditionally omits a property that the base mapping otherwise does populate -
@DtoIgnore is unconditional, applying to every variant including the base, because the
property can never be populated from the source at all, under any circumstance.
A primitive-typed property cannot be marked @DtoIgnore - there's no type-safe "absent"
value for it.
This is purely a compile-time / codegen-time hint - the DTO itself remains a plain, framework-free type with no runtime dependency on this annotation.