MILK - Java database framework Wiki
Lightweight Java database framework featuring a simple ORM
Status: Alpha
Brought to you by:
lvillap
This tutorial is based on the tests embedded in MILK's source code. You can find all code in it.
First of all: as we did when executing SQL queries over a database, we'll use a method to access MILK's ORM features. This method will be available only if our database extends from DbWithOrm (instead of Db). So, let's start:
import javax.sql.DataSource;
import net.sourceforge.milk.DbWithOrm;
import net.sourceforge.milk.orm.configuration.OrmConfigurationBuilder;
public class IssuesDbExamples extends DbWithOrm {
@Override
protected void configureOrm(final OrmConfigurationBuilder ormConfig) {
// Now we have to implement this method. Using the ormConfig parameter,
// we'll customize all the parameters of the ORM for our environment.
}
@Override
protected DataSource createDataSource() {
// ... as before ...
}
}
For now, we'll not configure anything, let's go step by step. Let's fetch an object by its id