MILK - Java database framework Wiki
Lightweight Java database framework featuring a simple ORM
Status: Alpha
Brought to you by:
lvillap
This section will be short. If you want to use complex conditions, you have to user filters. A Filter is a class that contains a part of a query string, and an array of parameters:
// This is a filter
Filter oneFilter = new Filter("userId>?", new Object[] { 1 });
// This is another filter
Filter anotherFilter = new Filter("deleted=?", new Object[] { false });
// ... and this is a filter that make an AND of the previous
Filter mixedFilter = oneFilter.and(anotherFilter);
So, let's retrieve an object using a filter:
final Issue issue = new IssuesDb().orm().loadOne(Issue.class,
new Filter("id=?", new Object[] { 1 }));
Done. We have retrieved our first objects from the database. Our next step is to fetch a collection of objects.
Wiki: Examples
Wiki: examples_toc
Wiki: orm_collection
Wiki: orm_get_by_id