Learn BxORM
Seventeen short lessons, from your first entity to a production boot, then five more to go further.
On this page
BxORM maps BoxLang classes to database tables. This course takes you from an empty folder to a small blog (users, posts and tags) running on BxORM, one short lesson at a time. Each lesson builds on the one before it and ends with a Try it section.
Your progress is remembered in this browser, so you can stop and pick up where you left off.
- Welcome to BxORMWhat an ORM does, what BxORM adds on top of Hibernate 7, and the blog you will build in this course.
- Install and configureInstall BxORM, point it at a database and run your first ORM script.
- Your first entityTurn a BoxLang class into a table with @persistent, then give it an id and typed properties.
- Save, load and deleteCreate users, save them, load them back by id or by a filter, change them and delete them.
- Static helpersLoad, find, count, create and bulk change entities straight from the class, like User::get( 1 ).
- RelationshipsConnect users, posts and tags with many-to-one, one-to-many and many-to-many relationships.
- Criteria queriesBuild queries in code with entityCriteria(): conditions, automatic joins, projections, paging and bulk changes.
- HQL, structs and queriesQuery with HQL, and turn entities into structs for a JSON API or into a query for reports.
- Transactions and the sessionCommit and roll back ORM work, see what changed before it is saved, lock rows and mix ORM with SQL safely.
- Events, soft delete and timestampsReact to inserts, updates and deletes, keep deleted posts in the table, and let BxORM stamp dates for you.
- Errors and observabilityRead and catch ORM errors, inspect the ORM with ormDiagnostics(), and watch your SQL in BxLens to find N+1 queries.
- Ship itProduction settings, the boot cache and the bxorm CLI for fast starts, and the second-level cache for fast reads.
- InheritanceShare columns with a mapped superclass, and model "kinds of" entities with single-table or joined inheritance.
- Testing ORM codeTest your entities and queries with TestBox, against a test database that resets itself, with every spec rolled back.
- BxORM with cbormUse BxORM inside a ColdBox app with cborm 6: entity services, virtual services, active entities and the same criteria builder.
- Building with AITeach your AI coding assistant how BxORM really works with the seven BxORM skills and the docs MCP server, then build a feature from a prompt.
- Coming from CFMLMove an existing CFML ORM app to BxORM: what carries over, which settings changed, and a step by step plan.
Before you start
You need:
- BoxLang 1.x installed, with the
boxlangandbx-modulecommands on your path. - A database you can create tables in. The lessons use MySQL, and every other database Hibernate supports works the same way.
- A little BoxLang: variables, functions and classes.
The first twelve lessons are the essentials. Lessons 13 to 17 go further: inheritance, testing, cborm, building with AI and moving an existing CFML app. Take those in any order.
Every lesson links to the full BxORM documentation for the details it leaves out.