How washmore/batchhacker works
Project type and purpose
• This is an open-source Java utility library (jar) called BatchHacker.
• Its goal is to transparently intercept and split large batch operations (lists/maps) so you never exceed MyBatis’s 2,100-parameter limit (or overwhelm any database) without touching existing business code.
File structure
• Top-level files:
• pom.xml → Maven coordinates & build config
• readme.md → usage guide
• src/main/java/tech/washmore/util/batchhacker → core interceptor + annotations
• Resources:
• src/main/resources/batchhacker/spring-aop.xml → AOP bean definitions
• No UI, no controllers, no REST endpoints—this is purely a library injected into a host Spring application.
README for insights
• Describes two integration modes: XML import of spring-aop.xml or @ImportResource in a SpringBoot starter.
• Annotation-driven: @BatchHacker on methods, optional @BatchHackerParam on specific List parameters.
• Runtime behavior: intercept method call, split input list(s) into sub-lists, invoke original logic multiple times, aggregate results.
a. Host Application (Spring Container)
• Your business Service or DAO class (with methods annotated @BatchHacker)
• spring-aop config or @ImportResource registering BatchHackerInterceptor bean
b. BatchHacker Library
• BatchHackerInterceptor (Spring AOP Advice)
• Annotation definitions: @BatchHacker, @BatchHackerParam
c. Underlying Persistence Layer
• MyBatis Mappers or JDBC template
• Database (e.g., Oracle, SQLServer, etc.)
d. (Optional) Maven Repository / Build
• Maven coordinates, artifact upload to nexus
Relationships & interactions
1. Client (other beans) calls a method in your Service/DAO annotated @BatchHacker.
2. Spring AOP proxy (created from spring-aop.xml) intercepts the call.
3. BatchHackerInterceptor reads annotation metadata, examines List/Map parameters.
4. It splits large collections into sub-lists of configurable size (<=2100).
5. For each sub-list, the interceptor invokes the original method on the target bean.
6. Those invocations flow into MyBatis (or JDBC) and hit the database as smaller batches.
7. Results (e.g., total inserted row counts) are aggregated, returned to the caller.
Architectural patterns & design principles
• AOP / Proxy pattern to weave in behavior without code changes
• Annotation-driven configuration for clarity & minimal intrusion
• Batch-split algorithm encapsulated in a single interceptor class
• Externalized configuration via spring-aop.xml
Relevant technologies/frameworks
• Java 8+
• Spring Framework (Core & AOP)
• MyBatis (or any JDBC‐based DAO)
• Maven for build & dependency management