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
+40
View File
@@ -0,0 +1,40 @@
# @BeforeMapping / @AfterMapping on a record target versus a bean target (call order, recorded)
--- target is a record: toRecord(Pair) ---
@BeforeMapping(source)
@BeforeMapping(source, @MappingTarget Boxed) target=Boxed[name=pen, qty=3]
@AfterMapping(source, @MappingTarget Boxed) target=Boxed[name=pen, qty=3]
@AfterMapping(source)
--- target is a mutable bean: toBean(Pair) ---
@BeforeMapping(source)
@BeforeMapping(source, @MappingTarget BoxedBean) name=null
BoxedBean.setName(pen)
BoxedBean.setQty(3)
@AfterMapping(source, @MappingTarget BoxedBean) name=pen
@AfterMapping(source)
--- the generated toRecord, which is why ---
public Probes.Boxed toRecord(Probes.Pair pair) {
beforeSource( pair );
if ( pair == null ) {
return null;
}
String name = null;
int qty = 0;
name = pair.name();
qty = pair.qty();
Probes.Boxed boxed = new Probes.Boxed( name, qty );
beforeRecord( pair, boxed );
afterRecord( pair, boxed );
afterSource( pair );
return boxed;
}