org.domdrides.mybatis.repository
Class MybatisRepository<EntityType extends Entity<IdType>,IdType extends Serializable>

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.mybatis.spring.support.SqlSessionDaoSupport
          extended by org.domdrides.mybatis.repository.MybatisRepository<EntityType,IdType>
All Implemented Interfaces:
Repository<EntityType,IdType>, org.springframework.beans.factory.InitializingBean

public class MybatisRepository<EntityType extends Entity<IdType>,IdType extends Serializable>
extends org.mybatis.spring.support.SqlSessionDaoSupport
implements Repository<EntityType,IdType>

An myBATIS-based repository implementation

Since:
1.7

Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
MybatisRepository(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.
 String getAddId()
           
 Set<EntityType> getAll()
          Returns all entities in this repository as a set.
 EntityType getById(IdType id)
          Returns the entity with the given id.
 String getGetAllId()
           
 String getGetByIdId()
           
 String getRemoveId()
           
 String getSizeId()
           
 String getUpdateId()
           
 void remove(EntityType entity)
          Removes the entity from this repository.
 void setAddId(String addId)
           
 void setGetAllId(String getAllId)
           
 void setGetByIdId(String getByIdId)
           
 void setRemoveId(String removeId)
           
 void setSizeId(String sizeId)
           
 void setUpdateId(String updateId)
           
 int size()
          Returns the size of the repository.
 EntityType update(EntityType entity)
          Updates an entity within this repository.
 
Methods inherited from class org.mybatis.spring.support.SqlSessionDaoSupport
checkDaoConfig, getSqlSession, setSqlSessionFactory, setSqlSessionTemplate
 
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
 

Constructor Detail

MybatisRepository

public MybatisRepository(Class<EntityType> entityClass)
Method Detail

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

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)

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

getSizeId

public String getSizeId()

setSizeId

public void setSizeId(String sizeId)

getAddId

public String getAddId()

setAddId

public void setAddId(String addId)

getGetAllId

public String getGetAllId()

setGetAllId

public void setGetAllId(String getAllId)

getGetByIdId

public String getGetByIdId()

setGetByIdId

public void setGetByIdId(String getByIdId)

getRemoveId

public String getRemoveId()

setRemoveId

public void setRemoveId(String removeId)

getUpdateId

public String getUpdateId()

setUpdateId

public void setUpdateId(String updateId)


Copyright © 2013. All Rights Reserved.