About BitSnippets
A small, opinionated publication about the Java libraries that quietly run production systems.
Why this site exists
Searching for “MyBatis dynamic SQL example” returns a hundred pages that all show the same
four-line <if> snippet and stop. None of them mention that <where>
only strips a leading AND, that OGNL treats 'Y' as a character
and not a string, or that a <foreach> over ten thousand IDs will blow past your
database's parameter limit.
BitSnippets is built around the belief that the interesting part of any framework is exactly the part that short tutorials skip. So we write long ones.
Editorial principles
- Every snippet compiles. Code is written inside a real project, run against a real database, and only then pasted in. Imports and configuration are shown when they are not obvious.
- Versions are stated. A tutorial without a version number has a shelf life of about eight months. Ours name the exact MyBatis, Spring Boot and JDK releases used.
- Trade-offs, not evangelism. MyBatis is excellent at some things and a poor fit for others. We say which is which, including where Hibernate or plain JDBC wins.
- Failure modes get equal billing. Every chapter ends with the mistakes people actually make — the stack traces, the silent nulls, the N+1 that only appears once the table has a million rows.
- No dark patterns. No newsletter interstitials, no “read 3 free articles”, no paywall. The site is funded by advertising instead — clearly labelled, never mixed into the prose, and never a paid link inside a tutorial. You can decline personalised ads, or decline personalised advertising, without losing access to anything.
How the site is built
Deliberately boring: hand-written HTML, one stylesheet, two small scripts, and SVG diagrams authored by hand so they stay crisp and readable in both light and dark themes. There is no build step, no framework and no runtime dependency — the entire site can be served from any static host or opened directly from disk.
| Layer | Choice | Why |
|---|---|---|
| Markup | Static HTML5 | Fast, indexable, zero runtime cost |
| Styling | One CSS file, custom properties | Theming without a preprocessor |
| Highlighting | ~150 lines of vanilla JS | No 400 KB syntax library for six languages |
| Diagrams | Hand-authored SVG | Scales, prints, and stays accessible via titles |
| Search | Client-side index | No server, no analytics on your queries |
| Ads | Lazy, height-reserved slots | Revenue without wrecking layout stability |
Who this is for
Backend developers who are comfortable with Java and SQL, and who want to understand the library rather than memorise its snippets. If you can read a stack trace and write a JOIN, you are the target reader. If you are brand new to SQL, read a SQL primer first — MyBatis assumes you already know what you want the database to do.
Found a mistake, an outdated API, or a pitfall we missed? Tell us on the contact page. Technical corrections get priority over everything else.
Reusing the material
Code snippets in the tutorials are provided as-is for you to copy into your own projects, commercial or otherwise. Prose and diagrams are © BitSnippets — quote a paragraph with attribution and a link, but please do not republish whole chapters.