K
- the key type.V
- the valye type.public class DefaultCachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable> extends Object implements CachedGroupJPAEntityRepository<K,V>
CachedGroupJPAEntityRepository
.CachedGroupJPAEntityRepository
Constructor and Description |
---|
DefaultCachedGroupJPAEntityRepository(String group,
Class<? extends CachedGroupJPAEntity<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 and with the "group".
|
int |
deleteAll()
Delete all rows from the table with this "group"
|
int |
deleteAll(Date belowExpireDateTime)
Delete all rows from this table where "
CachedGroupJPAEntity.getExpireDateTime() " is below belowExpireDateTime and with this "group". |
CachedGroupJPAEntity<K,V> |
get(K key)
Gets a row with the key and group.
|
List<CachedGroupJPAEntity<K,V>> |
getAll()
Get all rows from the table with this "group"
|
Class<? extends CachedGroupJPAEntity<K,V>> |
getEntityClazz()
Gets the class instance of CachedGroupJPAEntity.
|
javax.persistence.EntityManagerFactory |
getEntityManagerFactory()
Gets the EntityManagerFactory.
|
String |
getGroup()
Gets the group name for this repository, is part of the ID for CachedGroupJPAEntity.
|
void |
insert(CachedGroupJPAEntity<K,V> entity)
This will insert a row in the table with the "group".
|
long |
size()
The number of rows in the table with the "group".
|
void |
updateExpireTime(K key,
Date expireDateTime)
Update the "expireDateTime" column for a key on with the "group.
|
void |
validate()
Should validate that the "entityManagerFactory" is not
null , the entity clazz is not null , and the group is not null or empty, or the entity clazz do not have a "@Entity" annotation. |
public DefaultCachedGroupJPAEntityRepository(String group, Class<? extends CachedGroupJPAEntity<K,V>> entityClazz, javax.persistence.EntityManagerFactory entityManagerFactory) throws NullPointerException, IllegalArgumentException
group
- the group name of the repository, must be not null
and none empty.entityClazz
- the class instance of CachedGroupJPAEntity.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.
validate()
public final Class<? extends CachedGroupJPAEntity<K,V>> getEntityClazz()
CachedGroupJPAEntityRepository
getEntityClazz
in interface CachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable>
public void validate() throws NullPointerException, IllegalArgumentException
CachedGroupJPAEntityRepository
null
, the entity clazz is not null
, and the group is not null
or empty, or the entity clazz do not have a "@Entity" annotation.validate
in interface CachedGroupJPAEntityRepository<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.CachedGroupJPAEntityRepository.getEntityClazz()
,
CachedGroupJPAEntityRepository.getEntityManagerFactory()
,
CachedGroupJPAEntityRepository.getGroup()
public List<CachedGroupJPAEntity<K,V>> getAll() throws javax.persistence.PersistenceException
CachedGroupJPAEntityRepository
getAll
in interface CachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable>
javax.persistence.PersistenceException
- if unable to get all rows.CachedGroupJPAEntityRepository.getGroup()
public int deleteAll() throws javax.persistence.PersistenceException
CachedGroupJPAEntityRepository
deleteAll
in interface CachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable>
javax.persistence.PersistenceException
- if unable to performed deletion.CachedGroupJPAEntityRepository.getGroup()
public CachedGroupJPAEntity<K,V> get(K key) throws javax.persistence.PersistenceException
CachedGroupJPAEntityRepository
get
in interface CachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable>
key
- the key.null
is returned.javax.persistence.PersistenceException
- if unable to perform find.CachedGroupJPAEntityRepository.getGroup()
public void insert(CachedGroupJPAEntity<K,V> entity) throws javax.persistence.PersistenceException
CachedGroupJPAEntityRepository
insert
in interface CachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable>
entity
- the entity instance.javax.persistence.PersistenceException
- if unable to perform persist.CachedGroupJPAEntityRepository.getGroup()
,
CachedGroupJPAID.setGroup(String)
public long size() throws javax.persistence.PersistenceException
CachedGroupJPAEntityRepository
size
in interface CachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable>
javax.persistence.PersistenceException
- if unable to performed query.CachedGroupJPAEntityRepository.getGroup()
public void updateExpireTime(K key, Date expireDateTime) throws javax.persistence.PersistenceException
CachedGroupJPAEntityRepository
updateExpireTime
in interface CachedGroupJPAEntityRepository<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.CachedGroupJPAEntityRepository.getGroup()
public int deleteAll(Date belowExpireDateTime) throws javax.persistence.PersistenceException
CachedGroupJPAEntityRepository
CachedGroupJPAEntity.getExpireDateTime()
" is below belowExpireDateTime and with this "group".deleteAll
in interface CachedGroupJPAEntityRepository<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()
,
CachedGroupJPAEntityRepository.getGroup()
public void delete(K key) throws javax.persistence.PersistenceException
CachedGroupJPAEntityRepository
delete
in interface CachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable>
key
- the keyjavax.persistence.PersistenceException
- if unable to performed deletion.CachedGroupJPAEntityRepository.getGroup()
public javax.persistence.EntityManagerFactory getEntityManagerFactory()
CachedGroupJPAEntityRepository
getEntityManagerFactory
in interface CachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable>
public final String getGroup()
CachedGroupJPAEntityRepository
getGroup
in interface CachedGroupJPAEntityRepository<K extends Serializable,V extends Serializable>
null
and none empty.Copyright © 2016. All rights reserved.