Java Database Application Library

Get JDAL (Java Database Application Library) at Fast, secure and Free Open Source software downloads

Data Access Objects

The interface info.joseluismartin.dao.Dao extends PageableDataSource adding the classic CRUD operations (create, retrieve, update, delete) upon entities.

Whilst some developers rather use generic DAOs, others prefer just generalize retrieve methods. Both styles are available in the Dao interface which provides the following entity retrieving generic methods:

As well as the default entity retrieving methods.

The three Dao interface implementations included in JDAL are thread safe, so they are usually deployed into the application context as singletons.

Although JDAL may be used without the Spring Framework IoC container, the library has been designed folllowing the Dependency Injection principles, being consequently easier using it with the IoC container.

JDAL Core defines the namespace which simplifies the definition of persistence services in the container beans definition file of Spring Framework.

For example, In order to provide a DAO for the entity org.example.Entity, you just need to declare the service in the application context file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
    <!-- Daos -->
    <jdal:service entity="org.example.Entity" />


Often, filtering methods should be provided when requesting data from a repository. JDAL also offers two user objects for getting paged results from persistence services: Filter y CriteriaBuilder.

Most of the times, these are just the two classes that the user needs to code in the application data access layer. I've put special interest on simplifying this application specific task as much as possible.

DAO interface implementations contain a map associating CriteriaBuilders with a name (String). CriteriaBuilders create Criteria instances, if using Hibernate or CriteriaQueries given the case we are using JPA.

The Filter interface provides the filtering parameters for building each Criteria type. The selection of the CriteriaBuilder associated which each filter type is done by the filter name (ie, filter.getFilterName()).

BeanFilter class is a base class for filters created as simple JavaBeans.

JpaCriteriaBuilderSupport and AbstractCriteriaBuilder classes provide templates intended to simplify CriteriaBuilder creation for JPA and Hibernate.

CriteriaBuilders can be declared into application context using the <jdal:criteria> element. This element specifies the name of the CriteriaBuilder into the name attribute and a reference to a context defined bean into the builder attribute.

CriteriaBuilders are not the only way to get filtered results. On behalf of DAO type other implementation dependent procedures are supported.

As an example follows HibernateDao algorithm when a filtered page request is received.

When using JpaDao, if the filter name matches with a named query, the query will be executed using the parameters from filter.getParamenterMap()