New posts for Spring and Hibernate

This commit is contained in:
2026-11-06 01:05:27 +05:30
parent 51913ad9d4
commit dc13293046
136 changed files with 5268 additions and 0 deletions
@@ -0,0 +1,31 @@
# Post-processing a record: @AfterMapping on its builder, or a @DecoratedWith decorator
--- ReceiptMapper: the hook receives ReceiptDto.Builder ---
ReceiptDto[orderId=100, total=32.50, summary=order 100: 2 line(s)]
public ReceiptDto toReceipt(Order order) {
if ( order == null ) {
return null;
}
ReceiptDto.Builder receiptDto = ReceiptDto.builder();
receiptDto.orderId( order.getId() );
receiptDto.total( orderMapper.sumOfLines( order.getLines() ) );
summarise( order, receiptDto );
return receiptDto.build();
}
--- InvoiceMapper: @DecoratedWith, so two beans implement the interface ---
bean invoiceMapperImpl -> InvoiceMapperImpl
bean invoiceMapperImpl_ -> InvoiceMapperImpl_
injected InvoiceMapper (the @Primary one) : InvoiceDto[id=100, status=PAID, total=32.50, display=#100 [PAID] 32.50]
the generated delegate on its own : InvoiceDto[id=100, status=PAID, total=32.50, display=null]
--- the generated class that decorates ---
@Component
@Primary
public class InvoiceMapperImpl extends InvoiceMapperDecorator {
}