|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.domian.repository.AbstractRepository<T> net.sourceforge.domian.repository.AbstractDomianCoreRepository<T> net.sourceforge.domian.repository.HibernateRepository<T>
public class HibernateRepository<T extends Entity>
This repository implementation is based on the Hibernate object-relational mapping (ORM) tool, and its implementation of the Java Persistence API 1.0 (JPA). The Hibernate Query Language (HQL) is used as a fallback solution for both JPA EntityManager and JPA Query Language (JPQL) where suitable.
Highly experimental code as it has yet to be in any form of serious use. The only tested RDBMS is H2. Conversion of specification object graph to JPQL/HQL is not yet completed! Partitioning of this repository is not yet completed! This repository has a table naming convention: all table names must end_TABLE
.
In your JPA ORM configuration file, you must explicitely configure all table names ending with _TABLE
.
JPA does not seem to allow custom naming strategies...
The persistence definition supported by this repository is PersistenceDefinition.DELEGATED
.
Nested Class Summary | |
---|---|
protected class |
HibernateRepository.HibernateRepositoryIterator<V extends T>
Custom iterator class for HibernateRepository . |
protected class |
HibernateRepository.Update
|
Field Summary | |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
configurationMap
|
protected java.lang.ThreadLocal<javax.persistence.EntityManager> |
entityManager
|
protected javax.persistence.EntityManagerFactory |
entityManagerFactory
|
protected net.sourceforge.domian.repository.Rdbms |
rdbms
|
protected java.lang.String |
rdbmsServerName
|
protected java.io.File |
repositoryDirectory
|
protected java.lang.String |
repositoryDirectoryString
|
protected java.lang.String |
repositoryId
|
protected java.lang.String |
repositoryRootDirectoryString
|
protected java.util.List<java.lang.String> |
tableNameList
|
Fields inherited from class net.sourceforge.domian.repository.AbstractDomianCoreRepository |
---|
DEFAULT_DOMIAN_ROOT_DIR_NAME, DEFAULT_DOMIAN_ROOT_PATH, log, synchronizer |
Fields inherited from class net.sourceforge.domian.repository.AbstractRepository |
---|
supportsRecursiveIndexing, usesNativePartitioningSupport |
Constructor Summary | |
---|---|
HibernateRepository(net.sourceforge.domian.repository.Rdbms rdbms,
java.lang.String repositoryId)
|
|
HibernateRepository(net.sourceforge.domian.repository.Rdbms rdbms,
java.lang.String rdbmsServerName,
java.lang.String repositoryRootDirectoryString,
java.lang.String repositoryId)
|
|
HibernateRepository(net.sourceforge.domian.repository.Rdbms rdbms,
java.lang.String rdbmsServerName,
java.lang.String repositoryRootDirectoryString,
java.lang.String repositoryId,
java.util.Map<java.lang.String,java.lang.String> configurationMap)
|
Method Summary | ||
---|---|---|
void |
close()
Closes the repository and releases all resources. |
|
protected java.lang.Boolean |
contains(T entity)
|
|
|
findAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification. |
|
|
findSingleEntitySpecifiedBy(Specification<V> specification)
Finds and returns one single entity approved by the given specification. |
|
protected javax.persistence.EntityManager |
getEntityManager()
|
|
java.lang.String |
getFormat()
|
|
static java.lang.String |
getJpaPersistenceUnitName()
|
|
EntityPersistenceMetaData |
getMetaDataFor(T entity)
|
|
PersistenceDefinition |
getPersistenceDefinition()
|
|
java.io.File |
getRepositoryDirectory()
The unique file directory in which the repository data files resides. |
|
java.lang.String |
getRepositoryId()
The repository-ID the name of the repository. |
|
|
iterateAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification. |
|
void |
load()
The semantics of this operation depends on the Repository 's PersistenceDefinition . |
|
protected void |
onMakePartition()
Template method for partitioning callbacks. |
|
void |
persist()
The semantics of this operation depends on the Repository 's PersistenceDefinition . |
|
|
put(V entity)
Puts the given entity into this repository. |
|
|
remove(V entity)
Removes the given entity from this repository. |
|
java.lang.Long |
removeAllEntities()
Extra method Purges all entities in repository without no further ado. |
|
|
removeAllEntitiesSpecifiedBy(Specification<V> specification)
Removes all entities approved by the given specification. |
|
void |
removeAllRecordsInTable(java.lang.String tableName)
Extra method Purges all records in givan table without no further ado. |
|
|
update(V entity)
Updates an entity. |
|
|
update(V entity,
Specification<?> deltaSpecification)
Updates an entity. |
Methods inherited from class net.sourceforge.domian.repository.AbstractDomianCoreRepository |
---|
createUniqueSpecificationFor, getSynchronizer, makePartition, setSynchronizer |
Methods inherited from class net.sourceforge.domian.repository.AbstractRepository |
---|
count, countAll, countAllEntitiesSpecifiedBy, find, findAll, findSingle, isIndexingEntitiesRecursively, isPartitioningNatively, iterate, iterateAll, putAll, remove, removeAll |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sourceforge.domian.repository.Repository |
---|
count, countAll, countAllEntitiesSpecifiedBy, find, findAll, findSingle, isIndexingEntitiesRecursively, isPartitioningNatively, iterate, iterateAll, makePartition, putAll, remove, removeAll |
Field Detail |
---|
protected net.sourceforge.domian.repository.Rdbms rdbms
protected java.lang.String rdbmsServerName
protected java.lang.String repositoryRootDirectoryString
protected java.lang.String repositoryId
protected java.util.Map<java.lang.String,java.lang.String> configurationMap
protected java.lang.String repositoryDirectoryString
protected java.io.File repositoryDirectory
protected javax.persistence.EntityManagerFactory entityManagerFactory
protected java.util.List<java.lang.String> tableNameList
protected final java.lang.ThreadLocal<javax.persistence.EntityManager> entityManager
Constructor Detail |
---|
public HibernateRepository(net.sourceforge.domian.repository.Rdbms rdbms, java.lang.String repositoryId)
public HibernateRepository(net.sourceforge.domian.repository.Rdbms rdbms, java.lang.String rdbmsServerName, java.lang.String repositoryRootDirectoryString, java.lang.String repositoryId)
public HibernateRepository(net.sourceforge.domian.repository.Rdbms rdbms, java.lang.String rdbmsServerName, java.lang.String repositoryRootDirectoryString, java.lang.String repositoryId, java.util.Map<java.lang.String,java.lang.String> configurationMap)
Method Detail |
---|
public static java.lang.String getJpaPersistenceUnitName()
protected javax.persistence.EntityManager getEntityManager()
protected void onMakePartition()
AbstractRepository
onMakePartition
in class AbstractDomianCoreRepository<T extends Entity>
protected java.lang.Boolean contains(T entity)
contains
in class AbstractRepository<T extends Entity>
public <V extends T> java.util.Iterator<V> iterateAllEntitiesSpecifiedBy(Specification<V> specification)
Repository
iterateAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
specification
- the entity specification
public <V extends T> java.util.Collection<V> findAllEntitiesSpecifiedBy(Specification<V> specification)
Repository
findAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
specification
- the entity specification
public <V extends T> V findSingleEntitySpecifiedBy(Specification<V> specification)
Repository
findSingleEntitySpecifiedBy
in interface Repository<T extends Entity>
findSingleEntitySpecifiedBy
in class AbstractRepository<T extends Entity>
specification
- the entity specification
null
if no entity is foundpublic <V extends T> void put(V entity)
Repository
put
in interface Repository<T extends Entity>
entity
- the entity to be storedpublic <V extends T> void update(V entity)
Repository
PersistenceDefinition.FILE
, and possibly PersistenceDefinition.DELEGATED
...
For all other persistence definitions, this method is redundant/not applicable.
Anyway, by applying this method in a consistent manner, an eventual repository migration will not need any code changes.
update
in interface Repository<T extends Entity>
public <V extends T> void update(V entity, Specification<?> deltaSpecification)
Repository
PersistenceDefinition.FILE
, and possibly PersistenceDefinition.DELEGATED
...
For all other persistence definitions, this method is redundant/not applicable.
Anyway, by applying this method in a consistent manner, an eventual repository migration will not need any code changes.
update
in interface Repository<T extends Entity>
update
in class AbstractRepository<T extends Entity>
V
- the entity typeentity
- the entitydeltaSpecification
- for optimistic locking schemes: a specification specifying the differences/added state between this update and the previously retrieved entity version
The specification should be a conjuction of field bound equality specifications only,
or null
if optimistic locking with automatic retries is completely out of scopepublic void removeAllRecordsInTable(java.lang.String tableName)
public java.lang.Long removeAllEntities()
public <V extends T> java.lang.Long removeAllEntitiesSpecifiedBy(Specification<V> specification)
Repository
removeAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
specification
- the entity specification
public <V extends T> java.lang.Boolean remove(V entity)
Repository
remove
in interface Repository<T extends Entity>
entity
- the entity to be removed
true
if the entity is found and removed, otherwise false
public java.io.File getRepositoryDirectory()
PersistentRepository
getRepositoryDirectory
in interface PersistentRepository<T extends Entity>
public java.lang.String getRepositoryId()
PersistentRepository
getRepositoryId
in interface PersistentRepository<T extends Entity>
public PersistenceDefinition getPersistenceDefinition()
getPersistenceDefinition
in interface PersistentRepository<T extends Entity>
public java.lang.String getFormat()
getFormat
in interface PersistentRepository<T extends Entity>
public void load()
PersistentRepository
Repository
's PersistenceDefinition
.
load
in interface PersistentRepository<T extends Entity>
public void persist()
PersistentRepository
Repository
's PersistenceDefinition
.
persist
in interface PersistentRepository<T extends Entity>
public EntityPersistenceMetaData getMetaDataFor(T entity)
getMetaDataFor
in interface PersistentRepository<T extends Entity>
public void close()
PersistentRepository
close
in interface PersistentRepository<T extends Entity>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |