K - the key type.V - the valye type.public class DefaultCachedJPAEntityRepository<K extends Serializable,V extends Serializable> extends Object implements CachedJPAEntityRepository<K,V>
CachedJPAEntityRepository.CachedJPAEntityRepository| Constructor and Description |
|---|
DefaultCachedJPAEntityRepository(Class<? extends CachedJPAEntity<K,V>> entityClazz,
javax.persistence.EntityManagerFactory entityManagerFactory)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
delete(K key)
This will delete a row in the table with the key.
|
int |
deleteAll()
Delete all rows from the table.
|
int |
deleteAll(Date belowExpireDateTime)
Delete all rows from this table where "
CachedJPAEntity.getExpireDateTime()" is below belowExpireDateTime. |
CachedJPAEntity<K,V> |
get(K key)
Gets a row with the key.
|
List<CachedJPAEntity<K,V>> |
getAll()
Get all rows from the table
|
Class<? extends CachedJPAEntity<K,V>> |
getEntityClazz()
Gets the class instance of CachedJPAEntity.
|
javax.persistence.EntityManagerFactory |
getEntityManagerFactory()
Gets the EntityManagerFactory.
|
void |
insert(CachedJPAEntity<K,V> entity)
This will insert a row in the table.
|
long |
size()
The number of rows in the table
|
void |
updateExpireTime(K key,
Date expireDateTime)
Update the "expireDateTime" column for a key.
|
void |
validate()
Should validate that the "entityManagerFactory" is not
null and the entity clazz is not null or the entity clazz do not have a "@Entity" annotation. |
public DefaultCachedJPAEntityRepository(Class<? extends CachedJPAEntity<K,V>> entityClazz, javax.persistence.EntityManagerFactory entityManagerFactory) throws NullPointerException, IllegalArgumentException
entityClazz - the class instance of CachedJPAEntity.entityManagerFactory - an instance of entityManagerFactory.IllegalArgumentException - see validate method, or if entityClazz do not have "@Entity" as annotation.NullPointerException - if either entityManagerFactory, queryEntityManager or entityClazz is null.public final Class<? extends CachedJPAEntity<K,V>> getEntityClazz()
CachedJPAEntityRepositorygetEntityClazz in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>public void validate()
throws NullPointerException,
IllegalArgumentException
CachedJPAEntityRepositorynull and the entity clazz is not null or the entity clazz do not have a "@Entity" annotation.validate in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>NullPointerException - if either of the above conditions is not true.IllegalArgumentException - if either of the above conditions is not true.CachedJPAEntityRepository.getEntityClazz(),
CachedJPAEntityRepository.getEntityManagerFactory()public List<CachedJPAEntity<K,V>> getAll() throws javax.persistence.PersistenceException
CachedJPAEntityRepositorygetAll in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>javax.persistence.PersistenceException - if unable to get all rows.public int deleteAll()
throws javax.persistence.PersistenceException
CachedJPAEntityRepositorydeleteAll in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>javax.persistence.PersistenceException - if unable to performed deletion.public CachedJPAEntity<K,V> get(K key) throws javax.persistence.PersistenceException
CachedJPAEntityRepositoryget in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>key - the key.null is returned.javax.persistence.PersistenceException - if unable to perform find.public void insert(CachedJPAEntity<K,V> entity) throws javax.persistence.PersistenceException
CachedJPAEntityRepositoryinsert in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>entity - the entity instance.javax.persistence.PersistenceException - if unable to perform persist.public long size()
throws javax.persistence.PersistenceException
CachedJPAEntityRepositorysize in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>javax.persistence.PersistenceException - if unable to performed query.public void updateExpireTime(K key, Date expireDateTime) throws javax.persistence.PersistenceException
CachedJPAEntityRepositoryupdateExpireTime in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>key - the key.expireDateTime - the new expire datetime for the key.javax.persistence.PersistenceException - if unable to perform update.public int deleteAll(Date belowExpireDateTime) throws javax.persistence.PersistenceException
CachedJPAEntityRepositoryCachedJPAEntity.getExpireDateTime()" is below belowExpireDateTime.deleteAll in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>belowExpireDateTime - the datetime a rows "getExpireDateTime()" has to be below.javax.persistence.PersistenceException - if unable to performed deletion.CommonCachedJPAEntity.getExpireDateTime()public void delete(K key) throws javax.persistence.PersistenceException
CachedJPAEntityRepositorydelete in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>key - the keyjavax.persistence.PersistenceException - if unable to performed deletion.public javax.persistence.EntityManagerFactory getEntityManagerFactory()
CachedJPAEntityRepositorygetEntityManagerFactory in interface CachedJPAEntityRepository<K extends Serializable,V extends Serializable>Copyright © 2016. All rights reserved.