net.sourceforge.domian.repository
Class HibernateRepository<T extends Entity>
java.lang.Object
net.sourceforge.domian.repository.AbstractRepository<T>
net.sourceforge.domian.repository.AbstractDomianCoreRepository<T>
net.sourceforge.domian.repository.HibernateRepository<T>
- All Implemented Interfaces:
- BinaryFormatRepository<T>, PersistentRepository<T>, Repository<T>
public class HibernateRepository<T extends Entity>
- extends AbstractDomianCoreRepository<T>
- implements BinaryFormatRepository<T>
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
.
- Since:
- 0.4.2
- Author:
- Eirik Torske
- See Also:
- Java Persistence API (JPA)
Constructor Summary |
HibernateRepository(Rdbms rdbms,
java.lang.String repositoryId)
|
HibernateRepository(Rdbms rdbms,
java.lang.String rdbmsServerName,
java.lang.String repositoryRootDirectoryString,
java.lang.String repositoryId)
|
HibernateRepository(Rdbms rdbms,
java.lang.String rdbmsServerName,
java.lang.String repositoryRootDirectoryString,
java.lang.String repositoryId,
java.util.Map<java.lang.String,java.lang.String> configurationMap)
|
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 |
rdbms
protected Rdbms rdbms
rdbmsServerName
protected java.lang.String rdbmsServerName
repositoryRootDirectoryString
protected java.lang.String repositoryRootDirectoryString
repositoryId
protected java.lang.String repositoryId
configurationMap
protected java.util.Map<java.lang.String,java.lang.String> configurationMap
repositoryDirectoryString
protected java.lang.String repositoryDirectoryString
repositoryDirectory
protected java.io.File repositoryDirectory
entityManagerFactory
protected javax.persistence.EntityManagerFactory entityManagerFactory
tableNameList
protected java.util.List<java.lang.String> tableNameList
entityManager
protected final java.lang.ThreadLocal<javax.persistence.EntityManager> entityManager
HibernateRepository
public HibernateRepository(Rdbms rdbms,
java.lang.String repositoryId)
HibernateRepository
public HibernateRepository(Rdbms rdbms,
java.lang.String rdbmsServerName,
java.lang.String repositoryRootDirectoryString,
java.lang.String repositoryId)
HibernateRepository
public HibernateRepository(Rdbms rdbms,
java.lang.String rdbmsServerName,
java.lang.String repositoryRootDirectoryString,
java.lang.String repositoryId,
java.util.Map<java.lang.String,java.lang.String> configurationMap)
createEntityManager
private javax.persistence.EntityManager createEntityManager()
getJpaPersistenceUnitName
public static java.lang.String getJpaPersistenceUnitName()
getEntityManager
protected javax.persistence.EntityManager getEntityManager()
onMakePartition
protected void onMakePartition()
- Overrides:
onMakePartition
in class AbstractDomianCoreRepository<T extends Entity>
getTableNames
java.util.List<java.lang.String> getTableNames()
contains
protected java.lang.Boolean contains(T entity)
- Overrides:
contains
in class AbstractRepository<T extends Entity>
iterateAllEntitiesSpecifiedBy
public <V extends T> java.util.Iterator<V> iterateAllEntitiesSpecifiedBy(Specification<V> specification)
- Specified by:
iterateAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
findAllEntitiesSpecifiedBy
public <V extends T> java.util.Collection<V> findAllEntitiesSpecifiedBy(Specification<V> specification)
- Specified by:
findAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
findSingleEntitySpecifiedBy
public <V extends T> V findSingleEntitySpecifiedBy(Specification<V> specification)
- Specified by:
findSingleEntitySpecifiedBy
in interface Repository<T extends Entity>
- Overrides:
findSingleEntitySpecifiedBy
in class AbstractRepository<T extends Entity>
put
public <V extends T> void put(V entity)
- Specified by:
put
in interface Repository<T extends Entity>
update
public <V extends T> void update(V entity)
- Specified by:
update
in interface Repository<T extends Entity>
update
public <V extends T> void update(V entity,
Specification<?> deltaSpecification)
- Specified by:
update
in interface Repository<T extends Entity>
- Overrides:
update
in class AbstractRepository<T extends Entity>
removeAllRecordsInTable
public void removeAllRecordsInTable(java.lang.String tableName)
- Extra method
Purges all records in givan table without no further ado.
removeAllEntities
public java.lang.Long removeAllEntities()
- Extra method
Purges all entities in repository without no further ado.
removeAllEntitiesSpecifiedBy
public <V extends T> java.lang.Long removeAllEntitiesSpecifiedBy(Specification<V> specification)
- Specified by:
removeAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
remove
public <V extends T> java.lang.Boolean remove(V entity)
- Specified by:
remove
in interface Repository<T extends Entity>
getRepositoryDirectory
public java.io.File getRepositoryDirectory()
- Specified by:
getRepositoryDirectory
in interface PersistentRepository<T extends Entity>
getRepositoryId
public java.lang.String getRepositoryId()
- Specified by:
getRepositoryId
in interface PersistentRepository<T extends Entity>
getPersistenceDefinition
public PersistenceDefinition getPersistenceDefinition()
- Specified by:
getPersistenceDefinition
in interface PersistentRepository<T extends Entity>
getFormat
public java.lang.String getFormat()
- Specified by:
getFormat
in interface PersistentRepository<T extends Entity>
load
public void load()
- Specified by:
load
in interface PersistentRepository<T extends Entity>
persist
public void persist()
- Specified by:
persist
in interface PersistentRepository<T extends Entity>
getMetaDataFor
public EntityPersistenceMetaData getMetaDataFor(T entity)
- Specified by:
getMetaDataFor
in interface PersistentRepository<T extends Entity>
close
public void close()
- Specified by:
close
in interface PersistentRepository<T extends Entity>
Copyright © 2009-2010. All Rights Reserved.