info.joseluismartin.dao
Interface Dao<T,PK extends Serializable>

All Superinterfaces:
PageableDataSource<T>
All Known Subinterfaces:
ReportDao, UserDao
All Known Implementing Classes:
HibernateDao, HibernateReportDao, IBatisDao, JpaDao

public interface Dao<T,PK extends Serializable>
extends PageableDataSource<T>

Generic DAO with pageable datasource interface.

Author:
Jose Luis Martin - (jlm@joseluismartin.info)

Method Summary
 void delete(T entity)
          Delete an entity
 void deleteById(PK id)
          Delete an object by primary key
 boolean exists(PK id)
          Checks for existence of an object of type T using the id arg.
 List<T> findByNamedQuery(String queryName, Map<String,Object> queryParams)
          Find a list of records by using a named query
 T get(PK id)
          Find object by id
<E> E
get(PK id, Class<E> clazz)
           
 List<T> getAll()
          Get all models
<E> List<E>
getAll(Class<E> clazz)
           
 T initialize(T entity)
          Initalize entity at default depth
 T initialize(T entity, int depth)
          Initalize entity
 T save(T object)
          Save or update an object
 
Methods inherited from interface info.joseluismartin.dao.PageableDataSource
getKeys, getPage
 

Method Detail

getAll

List<T> getAll()
Get all models

Returns:
List of entities

get

T get(PK id)
Find object by id

Parameters:
id - the identifier (primary key) of the object to get
Returns:
entity or null if none

exists

boolean exists(PK id)
Checks for existence of an object of type T using the id arg.

Parameters:
id - the id of the entity
Returns:
- true if it exists, false if it doesn't

save

T save(T object)
Save or update an object

Parameters:
object - the object to save
Returns:
the persisted object

deleteById

void deleteById(PK id)
Delete an object by primary key

Parameters:
id - the primary key

delete

void delete(T entity)
Delete an entity

Parameters:
entity - to delete

findByNamedQuery

List<T> findByNamedQuery(String queryName,
                         Map<String,Object> queryParams)
Find a list of records by using a named query

Parameters:
queryName - query name of the named query
queryParams - a map of the query names and the values
Returns:
a list of the records found

initialize

T initialize(T entity)
Initalize entity at default depth

Parameters:
entity - to intialize
Returns:
intialized entity

initialize

T initialize(T entity,
             int depth)
Initalize entity

Parameters:
entity - to intialize
depth - to descend.
Returns:
intialized entity

get

<E> E get(PK id,
          Class<E> clazz)

getAll

<E> List<E> getAll(Class<E> clazz)


Copyright © 2012 JDAL. All Rights Reserved.