Ah yes, just what we need: another ORM...
PikaORM is an object-relational mapping tool for Java.
PikaORM is designed differently than most other Java ORM tools:
- It does not require any code-generation
- It works with POJOs
- It is configured entirely in code, no config files
- It doesn't hide the underlying SQL from you
- The source is in one file, and can be copied-and-pasted into your project if you wish to tweak or fork it
Here is an example of PikaORM in action:
// a POJO model classclassMyModel {
longid;
Stringstr;
}
publicstaticvoidmain(String[] args) {
// create an ORM with a connection stringvarorm = newPikaORM("jdbc:sqlite:demo.db");
// create a new model objectvarmodel = newMyModel();
model.str = "Hello PikaORM";
// save it to the database, get the resulting generated idvarid = orm.insert(model);
// load the model from db by idvarfromDb = orm.find(MyModel.class).byId(id);
// print out "Hello PikaORM"System.out.println(fromDb.str);
}The MyModel class in this example is a POJO and doesn't know
anything about the backing database.
In this case the schema for the table that holds this POJO would look like this:
CREATETABLEmy_models (
id INTEGERPRIMARY KEY,
str_val VARCHARNOT NULL
);ClassName->class_namesfieldName->field_nameid-> id column/field name<table_name>_id-> foreign key column/field nameversion-> optimistic concurrency column/field name