Jay Taylor's notes
back to listing indexJoist
[web search]
Original source (joist.ws)
Clipped on: 2013-12-12
Joist
Joist is a simple, productive Java ORM with no boilerplate, type-safe queries, and no runtime class generation.
How it Works
You write migrations to modify your schema:
- public class m0002 extends AbstractMigration {
- public m0002() {
- super("Add employee table.");
- }
- public void apply() {
- createTable("employee",
- primaryId("id"),
- varchar("name"),
- varchar("email").nullable(),
- integer("version"));
- }
- }
Run cycle
to update your database and get clean, getter/setter-free domain objects:
- public class Employee extends EmployeeCodegen {
- // put your business logic here, it won't get over written
- // getters/setters/collections are in the base class
- }
Now you can write type-safe queries:
- public class EmployeeQueries {
- public List<Employee> findByName(String name) {
- EmployeeAlias e = new EmployeeAlias("e");
- return Select.from(e).where(e.name.eq(name)).list();
- }
- }
The goal is a simple, “it just works” domain layer for enterprise-scale schemas.
To jump in, see getting started.
Screencast
Why Joist is Awesome
- Domain Objects that are clean, simple, and “just work”
- Type-Safe Queries that won’t compile if your schema changes
- Auto-Maintained Back Pointers so that parent/child collections are always in sync
- Validation Rules for consistently enforcing business logic
- Migrations for maintaining your schema
- Eager Loading to avoid the N+1 problem even in nested for loops
- Performance that is as-fast-or-faster than Hibernate
- Type-Safe Changed Properties
Implementation Details:
- Aliases facilitate writing type-safe queries
- Shims to map data instead of reflection or runtime-generated classes
- Patterns like Unit of Work, Identity Map, etc.
- Code Generation to avoid boilerplate
- Eclipse Tips
Blog posts:
- Joist Builder Defaults
- Joist, the Java ORM for Me
- Joist Tip–Fast Database Resets
- Joist vs. Hibernate SQL
Opinions
Joist is tailored for projects that agree with its opinions:
- Enterprise teams are best served by as much type safety as possible
- Domain objects should match and be driven by the schema
- PostgreSQL (and MySQL in ANSI mode) are the supported databases
- Waiting for your ORM to start shouldn’t kill your TDD loop
Community
- Source code: http://github.com/stephenh/joist
- Forum: https://groups.google.com/forum/#!forum/joist
Acknowledgements
Joist borrows ideas mainly from Rails (migrations and database-reflected-domain objects) and JaQu (type-safe SQL queries).