org.domdrides.jpa.repository
Class JpaRepository<EntityType extends Entity<IdType>,IdType extends Serializable>

java.lang.Object
  extended by org.domdrides.jpa.repository.JpaRepository<EntityType,IdType>
All Implemented Interfaces:
PageableRepository<EntityType,IdType>, Repository<EntityType,IdType>
Direct Known Subclasses:
JpaPersonRepository

@Repository
public abstract class JpaRepository<EntityType extends Entity<IdType>,IdType extends Serializable>
extends Object
implements PageableRepository<EntityType,IdType>


Constructor Summary
protected JpaRepository(Class<EntityType> entityClass)
           
 
Method Summary
 EntityType add(EntityType entity)
          Adds the entity to this repository.
 boolean contains(EntityType entity)
          Returns whether or not the entity is contained within the repository.
 Set<EntityType> getAll()
          Returns all entities in this repository as a set.
 EntityType getById(IdType id)
          Returns the entity with the given id.
protected  Class<EntityType> getEntityClass()
           
protected  javax.persistence.EntityManager getEntityManager()
           
 List<EntityType> list(int first, int max, String sortProperty, boolean ascending)
          Returns one page of data from this repository.
 void remove(EntityType entity)
          Removes the entity from this repository.
 int size()
          Returns the size of the repository.
 EntityType update(EntityType entity)
          Updates an entity within this repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JpaRepository

protected JpaRepository(Class<EntityType> entityClass)
Method Detail

list

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

Specified by:
list in interface PageableRepository<EntityType extends 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)
Description copied from interface: Repository
Adds the entity to this repository.

Specified by:
add in interface Repository<EntityType extends Entity<IdType>,IdType extends Serializable>
Parameters:
entity - the entity
Returns:
the entity (useful if adding entity to repository changes the entity, e.g. creates oid)

contains

@Transactional(readOnly=true)
public boolean contains(EntityType entity)
Description copied from interface: Repository
Returns whether or not the entity is contained within the repository.

Specified by:
contains in interface Repository<EntityType extends Entity<IdType>,IdType extends Serializable>
Parameters:
entity - the entity
Returns:
whether or not the entity is contained within the repository

getAll

@Transactional(readOnly=true)
public Set<EntityType> getAll()
Description copied from interface: Repository
Returns all entities in this repository as a set.

Specified by:
getAll in interface Repository<EntityType extends Entity<IdType>,IdType extends Serializable>
Returns:
all entities in this repository as a set

getById

@Transactional(readOnly=true)
public EntityType getById(IdType id)
Description copied from interface: Repository
Returns the entity with the given id.

Specified by:
getById in interface Repository<EntityType extends Entity<IdType>,IdType extends Serializable>
Parameters:
id - the id
Returns:
the entity with the given id

remove

@Transactional
public void remove(EntityType entity)
Description copied from interface: Repository
Removes the entity from this repository.

Specified by:
remove in interface Repository<EntityType extends Entity<IdType>,IdType extends Serializable>
Parameters:
entity - the entity

size

@Transactional(readOnly=true)
public int size()
Description copied from interface: Repository
Returns the size of the repository.

Specified by:
size in interface Repository<EntityType extends Entity<IdType>,IdType extends Serializable>
Returns:
the size of the repository

update

@Transactional
public EntityType update(EntityType entity)
Description copied from interface: Repository
Updates an entity within this repository.

Specified by:
update in interface Repository<EntityType extends Entity<IdType>,IdType extends Serializable>
Parameters:
entity - the entity
Returns:
the entity (useful if adding entity to repository changes the entity, e.g. creates oid)

getEntityClass

protected Class<EntityType> getEntityClass()

getEntityManager

protected javax.persistence.EntityManager getEntityManager()


Copyright © 2013. All Rights Reserved.