Skip to content

devMls/activejdbc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

915a0f3 · Sep 12, 2018
Aug 14, 2018
Jul 24, 2018
Aug 20, 2018
Aug 18, 2018
Sep 12, 2018
Aug 20, 2018
Jul 24, 2018
Jul 24, 2018
Apr 8, 2018
Jul 24, 2018
Mar 6, 2015
Aug 20, 2018
Mar 19, 2016
Nov 4, 2014
Aug 12, 2018
Jul 19, 2010
Aug 26, 2015
Aug 20, 2018
Feb 24, 2016

Repository files navigation

ActiveJDBC — ActiveRecord for Java

ActiveJDBC is a Java implementation of Active Record design pattern. It was inspired by ActiveRecord ORM from Ruby on Rails.

Design principles

  • Should infer metadata from DB (like ActiveRecord)
  • Should be very easy to work with
  • Should reduce amount of code to a minimum
  • No configuration, just conventions
  • Some conventions are overridable in code
  • No need to learn another language
  • No need to learn another QL — SQL is sufficient
  • Code must be lightweight and intuitive, should read like English
  • No sessions, no "attaching, re-attaching"
  • No persistence managers
  • No classes outside your own models
  • Models are lightweight, no transient fields
  • No proxying. What you write is what you get (WYSIWYG:))
  • Should have the least possible resistance to startup a project
  • No useless getters and setters (they just pollute code). You can still write them if you like.
  • No DAOs and DTOs — this is mostly junk code anyway

Simple example

For a simple example we will use a table called people created with this MySQL DDL:

CREATE TABLE people (
  id  int(11) NOT NULL auto_increment PRIMARY KEY, 
  name VARCHAR(56) NOT NULL, 
  last_name VARCHAR(56), 
  dob DATE, 
  graduation_date DATE, 
  created_at DATETIME, 
  updated_at DATETIME
);

ActiveJDBC infers DB schema parameters from a database. This means you do not have to provide it in code, the simplest example model looks like this:

public class Person extends Model {}

Despite the fact that there is no code in it, it is fully functional and will map to a table called people automatically.

Here is a simple query how to use the Person model:

List<Person> people = Person.where("name = 'John'");
Person aJohn =  people.get(0);
String johnsLastName = aJohn.get("last_name");

As you can see, the amount of code is reduced to a level when it is actually readable. Finder methods can also be parametrized like this:

List<Person> people = Person.where("name = ?", "John");
Person aJohn =  people.get(0);
String johnsLastName = aJohn.get("last_name");

Documentation

For more information, follow here: http://javalite.io

Acknowledgement

Special thanks to folks at IntelliJ for granting a license to this project

About

ActiveJDBC is a fast and lean Java ORM

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 94.1%
  • Kotlin 2.5%
  • PLSQL 2.5%
  • SQLPL 0.3%
  • Groovy 0.2%
  • PLpgSQL 0.2%
  • Other 0.2%