Jay Taylor's notes

back to listing index

Joist

[web search]
Original source (joist.ws)
Tags: orm java 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:

  1. public class m0002 extends AbstractMigration {  
  2.   public m0002() {  
  3.     super("Add employee table.");  
  4.   }  
  5.   
  6.   public void apply() {  
  7.     createTable("employee",  
  8.       primaryId("id"),  
  9.       varchar("name"),  
  10.       varchar("email").nullable(),  
  11.       integer("version"));  
  12.   }  
  13. }  

Run cycle to update your database and get clean, getter/setter-free domain objects:

  1. public class Employee extends EmployeeCodegen {  
  2.   // put your business logic here, it won't get over written  
  3.   
  4.   // getters/setters/collections are in the base class  
  5. }  

Now you can write type-safe queries:

  1. public class EmployeeQueries {  
  2.   public List<Employee> findByName(String name) {  
  3.     EmployeeAlias e = new EmployeeAlias("e");  
  4.     return Select.from(e).where(e.name.eq(name)).list();  
  5.   }  
  6. }  

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

Implementation Details:

Blog posts:

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

Acknowledgements

Joist borrows ideas mainly from Rails (migrations and database-reflected-domain objects) and JaQu (type-safe SQL queries).