Welcome to BxORM
What an ORM does, what BxORM adds on top of Hibernate 7, and the blog you will build in this course.
On this page
Most applications keep their data in a relational database: tables, rows and columns. Most application code thinks in objects: a user, a post, a tag. An ORM (object-relational mapper) connects the two. You describe a class once, and the ORM turns rows into objects when you load them and objects into rows when you save them.
BxORM is the ORM for BoxLang. It runs on Hibernate 7, the most widely used ORM on the JVM, and wraps it in a framework built for a dynamic language.
What BxORM adds on top of Hibernate
Hibernate on its own expects Java classes, XML mappings and a lot of casting. BxORM gives you:
- Classes as tables. A BoxLang class with
@persistentis an entity. No XML, no Java. - Generated methods. Getters, setters and relationship helpers like
addPosts()are generated for you. - Static helpers.
User::get( 1 ),User::findWhere( { email : "ann@example.com" } )andUser::count()on every entity. - A fluent criteria builder. Conditions, joins, projections and paging, always parameterized.
- No casting. BoxLang values are converted to the right JDBC type and back.
- Errors written for humans. A typo in an entity name says
There is no entity named [Usr]. Did you mean [User]? - A boot cache. Large models start much faster in production.
Here is a taste. This loads a user, finds their published posts and turns them into JSON-ready structs:
ann = User::getOrFail( 1 );
posts = Post::criteria()
.isEq( "author", ann )
.isTrue( "published" )
.order( "createdDate", "desc" )
.list();
println( entityToStruct( posts ) );
What you will build
Over the course you build a small blog with three entities:
| Entity | Table | What it holds |
|---|---|---|
User | users | An email, a name and the user's posts |
Post | posts | A title, a body, a published flag, an author and tags |
Tag | tags | A unique name |
Every lesson adds to the same app, so keep the folder you create in the next lesson.
How the course works
The first twelve lessons are the essentials:
- Welcome (this lesson)
- Install and configure
- Your first entity
- Save, load and delete
- Static helpers
- Relationships
- Criteria queries
- HQL, structs and queries
- Transactions and the session
- Events, soft delete and timestamps
- Errors and observability
- Ship it
Then five lessons go further, in any order: inheritance, testing, cborm, building with AI and coming from CFML.
Try it
- Think of an app you have built. Which of its tables would become entities?
- Pick one table and list its columns. Which would be a plain property, and which point at another table?