You can download it from it's project page here:
http://www.jenkov.dk/projects/mrpersister/mrpersister.jsp
Mr. Persister's main features and differences from other ORM API's are:
1) SQL as Query Language.
That means you don't have to learn a new query language in order to use Mr. Persister. If your database understands your SQL, so does Mr. Persister.
In addition to SQL Mr. Persister is capable of reading objects from
JDBC's ResultSet, Statement, and PreparedStatement instances too.
2) Mapping to SQL Queries
When reading Mr. Persister just iterates through the columns of the ResultSet and checks if they are mapped to a setter method on the object. Therefore the columns in the ResultSet don't have to exist in any table. As long as they exist in the ResultSet Mr. Persister can read objects from it. This makes it easy to map objects to complex joins, or aggregate functions like "select sum (...) from ... group by ..."
3) Automatic Mapping
Mr. Persister is capable of guessing most trivial mappings between classes and tables, and between getters / setters and columns. This way you save the work of creating manual mapping files.
You can also create manual mappings easily programmatically. Or you can use mixed mapping where you have Mr. Persister generate an automatic mapping that you modify before it's used.
4) Mr. Persister can generate SQL for trivial operations like readByPrimaryKey, insert, update, delete, deleteByPrimaryKey. This SQL is generated at request time (lazy evaluation) and cached for later use, so there is no startup SQL generation time penalty.
5) Mr. Persister supports batch updates (insert, update, delete, and deleteByPrimaryKey)
4) Mr. Persister uses reflection to move data between the JDBC components and the objects.
5) Small. 97 kb binary jar file.
6) Fast. 5% overhead on reads from MySQL.
7) Free. Released under the Apache License.
Using Mr. Persister can be done in just 3 simple steps:
1) Download the binary jar file.
2) Include the binary jar file on your classpath
3) Subclass com.jenkov.mrpersister.AbstractDao
The AbstractDao works as a facade to the Mr. Persister components and has a lot of protected methods your DAO subclass can make use of when implementing your own read and write methods. Below is an example of a simple DAO class that uses Mr. Persister and automatic mapping:
public class EmployeeDao extends AbstractDao {ORM won't get much easier than this, we believe.
protected Connection getConnection() throws PersistenceException {
//you need to override this method. It's used by the AbstractDAO methods.
}
public Employee readEmployee(String employeeId) throws PersistenceException{
return (Employee) readByPrimaryKey(Employee.class, employeeId);
}
public List readAllEmployees() throws PersistenceException{
return readList(Employee.class, "select * from employees");
}
public int insertEmployee(Employee employee) throws PersistenceException {
return insert(Employee.class, employee);
}
public int updateEmployee(Employee employee) throws PersistenceException {
return update(Employee.class, employee);
}
public int deleteEmployee(Employee employee) throws PersistenceException {
return delete(Employee.class, employee);
}
public int[] insertEmployees(List employees) throws PersistenceException {
return insertBatch(Employee.class, employees);
}
public int[] updateEmployees(List employees) throws PersistenceException {
return updateBatch(Employee.class, employees);
}
public int[] deleteEmployees(List employees) throws PersistenceException {
return deleteBatch(Employee.class, employees);
}
}
Check it out here:
http://www.jenkov.dk/projects/mrpersister/mrpersister.jsp