org.domdrides.hibernate.repository
Class HibernateRepository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by org.domdrides.hibernate.repository.HibernateRepository<EntityType,IdType>
All Implemented Interfaces:
org.domdrides.repository.PageableRepository<EntityType,IdType>, org.domdrides.repository.Repository<EntityType,IdType>, org.springframework.beans.factory.InitializingBean

@Repository
public abstract class HibernateRepository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>
extends org.springframework.orm.hibernate3.support.HibernateDaoSupport
implements org.domdrides.repository.PageableRepository<EntityType,IdType>

A Hibernate-based repository implementation.

Since:
1.0
Author:
James Carman

Field Summary
static String UNCHECKED
           
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
protected HibernateRepository(Class<EntityType> entityClass)
          Constructs a repository which supports entityClass.
 
Method Summary
 EntityType add(EntityType entity)
           
 boolean contains(EntityType entity)
           
protected  org.hibernate.Criteria createCriteria()
          Creates a Criteria object which returns the entity type.
 Set<EntityType> getAll()
           
 EntityType getById(IdType id)
           
protected  List<EntityType> list(org.hibernate.Criteria criteria)
          Returns a list of entities based on the provided criteria.
 List<EntityType> list(int first, int max, String sortProperty, boolean ascending)
          Returns one page of data from this repository.
protected  List<EntityType> list(org.hibernate.Query query)
          Returns a list of entities based on the provided query.
 void remove(EntityType entity)
           
protected  Set<EntityType> set(org.hibernate.Criteria criteria)
          Returns a set of entities based on the provided criteria.
protected  Set<EntityType> set(org.hibernate.Query query)
          Returns a set of entities based on the provided query.
 int size()
           
protected  EntityType uniqueResult(org.hibernate.Criteria criteria)
          Returns a unique result based on the provided criteria.
protected  EntityType uniqueResult(org.hibernate.Query query)
          Returns a unique result based on the provided query.
 EntityType update(EntityType entity)
           
 
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNCHECKED

public static final String UNCHECKED
See Also:
Constant Field Values
Constructor Detail

HibernateRepository

protected HibernateRepository(Class<EntityType> entityClass)
Constructs a repository which supports entityClass.

Parameters:
entityClass - the entity class
Method Detail

list

@Transactional(readOnly=true)
public List<EntityType> list(int first,
                                           int max,
                                           String sortProperty,
                                           boolean ascending)
Returns one page of data from this repository.

Specified by:
list in interface org.domdrides.repository.PageableRepository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>
Parameters:
first - the first entity to return
max - the maximum number of entities to return
sortProperty - the property to sort by
ascending - whether or not the sorting is asceding
Returns:
one page of data from this repository

add

@Transactional
public EntityType add(EntityType entity)
Specified by:
add in interface org.domdrides.repository.Repository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>

contains

@Transactional(readOnly=true)
public boolean contains(EntityType entity)
Specified by:
contains in interface org.domdrides.repository.Repository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>

getAll

@Transactional(readOnly=true)
public Set<EntityType> getAll()
Specified by:
getAll in interface org.domdrides.repository.Repository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>

getById

@Transactional(readOnly=true)
public EntityType getById(IdType id)
Specified by:
getById in interface org.domdrides.repository.Repository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>

remove

@Transactional
public void remove(EntityType entity)
Specified by:
remove in interface org.domdrides.repository.Repository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>

size

@Transactional(readOnly=true)
public int size()
Specified by:
size in interface org.domdrides.repository.Repository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>

update

@Transactional
public EntityType update(EntityType entity)
Specified by:
update in interface org.domdrides.repository.Repository<EntityType extends org.domdrides.entity.Entity<IdType>,IdType extends Serializable>

createCriteria

protected org.hibernate.Criteria createCriteria()
Creates a Criteria object which returns the entity type.

Returns:
a Criteria object which returns the entity type

list

@Transactional(readOnly=true)
protected List<EntityType> list(org.hibernate.Criteria criteria)
Returns a list of entities based on the provided criteria.

Parameters:
criteria - the criteria
Returns:
a list of entities based on the provided criteria

list

@Transactional(readOnly=true)
protected List<EntityType> list(org.hibernate.Query query)
Returns a list of entities based on the provided query.

Parameters:
query - the query
Returns:
a list of entities based on the provided query

set

@Transactional(readOnly=true)
protected Set<EntityType> set(org.hibernate.Criteria criteria)
Returns a set of entities based on the provided criteria.

Parameters:
criteria - the criteria
Returns:
a set of entities based on the provided criteria

set

@Transactional(readOnly=true)
protected Set<EntityType> set(org.hibernate.Query query)
Returns a set of entities based on the provided query.

Parameters:
query - the query
Returns:
a set of entities based on the provided query

uniqueResult

@Transactional(readOnly=true)
protected EntityType uniqueResult(org.hibernate.Criteria criteria)
Returns a unique result based on the provided criteria.

Parameters:
criteria - the criteria
Returns:
a unique result based on the provided criteria

uniqueResult

@Transactional(readOnly=true)
protected EntityType uniqueResult(org.hibernate.Query query)
Returns a unique result based on the provided query.

Parameters:
query - the query
Returns:
a unique result based on the provided query


Copyright © 2013. All Rights Reserved.