MotechDataRepository

public abstract class MotechDataRepository<T> extends AbstractRepository

This is a basic repository class with standard CRUD operations. It should be used by other repositories inside this package.

This class is also used as super class to create a repository related with the given entity schema in org.motechproject.mds.builder.EntityInfrastructureBuilder.

Parameters:
  • <T> – the type of class

Constructors

MotechDataRepository

protected MotechDataRepository(Class<T> classType)

MotechDataRepository

protected MotechDataRepository(Class<T> classType, int fetchDepth)

Methods

count

public long count(InstanceSecurityRestriction restriction)

count

public long count(String[] properties, Object[] values, InstanceSecurityRestriction restriction)

count

public long count(List<Property> properties, InstanceSecurityRestriction restriction)

countForFilters

public long countForFilters(Filters filters, InstanceSecurityRestriction restriction)

create

public T create(T object)

delete

public void delete(T object)

delete

public long delete(String property, Object value)

delete

public long delete(String property, Object value, InstanceSecurityRestriction restriction)

delete

public long delete(String[] properties, Object[] values, InstanceSecurityRestriction restriction)

detachedCopy

public T detachedCopy(T object)

evictAll

public void evictAll()

evictEntity

public void evictEntity(boolean withSubclasses)

evictOne

public void evictOne(T object)

exists

public boolean exists(String property, Object value)

exists

public boolean exists(String[] properties, Object[] values)

filter

public List<T> filter(Filters filters, QueryParams queryParams, InstanceSecurityRestriction restriction)

getClassType

public Class<T> getClassType()

getDetachedField

public Object getDetachedField(T instance, String field)

getPersistenceManager

public PersistenceManager getPersistenceManager()

retrieve

public T retrieve(Object key)

retrieve

public T retrieve(String property, Object value)

retrieve

public T retrieve(String property, Object value, InstanceSecurityRestriction restriction)

retrieve

public T retrieve(String[] properties, Object[] values)

retrieve

public T retrieve(String[] properties, Object[] values, InstanceSecurityRestriction restriction)

retrieveAll

public List<T> retrieveAll(Collection<Long> keys)

retrieveAll

public List<T> retrieveAll()

retrieveAll

public List<T> retrieveAll(InstanceSecurityRestriction restriction)

retrieveAll

public List<T> retrieveAll(String property, Object value)

retrieveAll

public List<T> retrieveAll(String property, Object value, InstanceSecurityRestriction restriction)

retrieveAll

public List<T> retrieveAll(String[] properties, Object[] values, InstanceSecurityRestriction restriction)

retrieveAll

public List<T> retrieveAll(String[] properties, Object[] values, QueryParams queryParams, InstanceSecurityRestriction restriction)

retrieveAll

public List<T> retrieveAll(QueryParams queryParams, InstanceSecurityRestriction restriction)

retrieveAll

public List<T> retrieveAll(List<Property> properties, InstanceSecurityRestriction restriction)

retrieveAll

public List<T> retrieveAll(List<Property> properties, QueryParams queryParams, InstanceSecurityRestriction restriction)

retrieveUnique

public T retrieveUnique(List<Property> properties, InstanceSecurityRestriction restriction)

setFieldTypeMap

public void setFieldTypeMap(Map<String, String> fieldTypeMap)

update

public T update(T object)