NOTE
Using MyBatis
Mapper definitions, parameter binding, result mapping, dynamic SQL, sessions, and safe transaction usage in MyBatis.
This is a historical learning note and may contain outdated or incomplete understanding.
Typical MyBatis code defines mapper methods and associates them with SQL through XML or annotations. Use bound parameters (#{...}) for values so the driver can safely bind them; ${...} performs textual substitution and requires strict control when used for identifiers/fragments.
Result maps handle column-to-property mapping and nested structures. Dynamic SQL should remain understandable and testable rather than becoming a second programming language inside XML.
SqlSession lifecycle and commit/rollback belong to a transaction boundary; in Spring integrations this is usually managed by the framework rather than manually shared across threads.