SourceForge.net

Overview

What is QueryObjectFactory?

QueryObjectFactory is a fast, lightweight runtime JDBC code generator providing support for CRUD (create, retrieve, update and delete) operations and stored procedure calls. It uses byte-code generation to create query object classes from query method specifications and annotations. QueryObjectFactory is database independent and is using the standard JDBC API. It provides mapping support for the standard Java datatypes.

It is not an ORM (object/relational mapping) tool such as Hibernate.

Why should I use QueryObjectFactory?

Writing JDBC Java code is quite repetitive and error prone. It can be difficult to implement correct exception handling that closes all resources when an exception is thrown. Refactoring of SQL statements and its getXyz() and setXyz() methods can as well lead to bugs that are hard to find.

QueryObjectFactory allows developers to specify rather than implement query methods and leave the boring task of writing the implementation to the JVM.

How do I use QueryObjectFactory?

In a nutshell to use QueryObjectFactory all you need to do is define a query method in an interface, add a Java annotation and ask QueryObjectFactory to implement a query class and return an instance:

public interface PersonDao extends BaseQuery { @Query(sql="select id {%%.id}, first_name {%%.firstName}, " + "last_name {%%.lastName} from person where last_name = {%1}") List<Person> findPersonsByName(String lastName) throws SQLException; } ... PersonDao personDao = QueryObjectFactory.createQueryObject(PersonDao.class); personDao.setConnection(connection); List<Person> personList = personDao.findPersonsByName("Smith");

Getting Started

Take a look at the introduction.