|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.schwarzrot.data.access.support.AbstractEntityManager de.schwarzrot.data.access.jdbc.JDBCEntityManager
public class JDBCEntityManager
implementation of an EntityManager
that uses JDBC-database access for
persistence. It uses DbUtil
-implementations to hide the database
implementation dependant stuff, so this class should work with other
databases too.
Field Summary |
---|
Fields inherited from class de.schwarzrot.data.access.support.AbstractEntityManager |
---|
appDefaults |
Constructor Summary | |
---|---|
JDBCEntityManager()
|
|
JDBCEntityManager(DataSource ds)
|
Method Summary | ||
---|---|---|
protected
|
checkExistance(E instance,
Connection conn,
DbUtil dbUtil)
checks whether the given instance already exists in persistence. |
|
void |
commit(TransactionResource<?> resource)
used to persist all changes made during transaction. |
|
|
countInstances(Class<E> entityType,
Connection conn)
|
|
protected int |
createInstance(Entity instance,
Connection conn,
DbUtil dbUtil)
|
|
TransactionResource<?> |
createTransactionResource(Transaction t)
create an abstract handle to storage. |
|
void |
execute(TransactionalOperation<?> tao)
execute a single step of ApplicationTransaction |
|
protected int |
find(List<?> resultList,
Class<?> entityType,
List<ConditionElement> args,
EntityDescriptor ed,
Connection conn,
DbUtil dbUtil,
boolean readRelated,
Collection<SortInfo> orderSequence)
internal call to read a number of entities. |
|
DataSource |
getDataSource()
|
|
protected
|
getEntity(E instance,
Class<? extends Entity> entityType,
long id,
Connection conn)
internal call to resolve a given instance. |
|
EntityDescriptor |
getEntityDescriptor(Class<?> entityType,
Connection conn)
|
|
EntityDescriptor |
getEntityDescriptor(Class<?> entityType,
TransactionResource<?> res)
accessor to description instances of entities. |
|
protected long |
instanceCount(Class<? extends Entity> entityType,
List<ConditionElement> args,
Connection conn)
|
|
protected
|
instanceFromResultSet(ResultSet rs,
Connection conn,
EntityDescriptor ed,
DbUtil dbUtil,
boolean readRelated)
|
|
protected long |
queryId(EntityDescriptor ed,
Date now,
String userName,
Connection conn,
DbUtil dbUtil)
|
|
protected int |
readProperties(List resultList,
Class entityType,
Collection<String> properties,
List<ConditionElement> args,
EntityDescriptor ed,
Connection conn,
DbUtil dbUtil,
int maxRows,
boolean readRelated,
boolean uniq,
Collection<SortInfo> orderSequence)
|
|
void |
releaseTransactionResource(TransactionResource<?> resource)
free given storage handle |
|
protected
|
remove(Class<E> entityType,
List<ConditionElement> args,
EntityDescriptor ed,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
removeChildren(E instance,
EntityDescriptor ed,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
removeRelated(Class<?> childEntityType,
E instance,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
resolveGroupedUnnamedChildren(E instance,
EntityDescriptor ed,
PropertyInfo pi,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
resolveNamedChildren(E instance,
EntityDescriptor ed,
PropertyInfo pi,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
resolveReferences(E instance,
EntityDescriptor ed,
PropertyInfo pi,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
resolveRelated(EntityDescriptor ed,
E instance,
Connection conn,
DbUtil dbUtil)
resolve all relations, that could be defined for an Entity . |
|
protected
|
resolveSingleForeign(E instance,
EntityDescriptor ed,
PropertyInfo pi,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
resolveUnnamedChildren(E instance,
EntityDescriptor ed,
PropertyInfo pi,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
resolveWeightedReferences(E instance,
EntityDescriptor ed,
PropertyInfo pi,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
resultSet2EList(ca.odell.glazedlists.EventList<E> resultList,
ResultSet rs,
Connection conn,
EntityDescriptor ed,
DbUtil dbUtil,
int maxRows,
boolean readRelated)
|
|
protected
|
resultSet2List(List<E> resultList,
ResultSet rs,
Connection conn,
EntityDescriptor ed,
DbUtil dbUtil,
int maxRows,
boolean readRelated)
|
|
protected
|
resultSet2TrList(ca.odell.glazedlists.TransactionList<E> resultList,
ResultSet rs,
Connection conn,
EntityDescriptor ed,
DbUtil dbUtil,
int maxRows,
boolean readRelated)
|
|
void |
rollback(TransactionResource<?> resource)
discards changes of given storage handle and marks Transaction as
failed. |
|
protected int |
save(Entity instance,
Connection conn,
DbUtil dbUtil)
internal call to bring an Entity to persistence. |
|
protected void |
saveForeigns(EntityDescriptor ed,
Entity instance,
Connection conn,
DbUtil dbUtil)
|
|
protected int |
saveInstance(Entity instance,
Connection conn,
DbUtil dbUtil)
|
|
protected void |
saveNamedChildren(EntityDescriptor ed,
Entity instance,
Connection conn,
DbUtil dbUtil)
|
|
protected
|
saveProperties(E instance,
Collection<String> propertyNames,
List<ConditionElement> args,
Connection conn,
DbUtil dbUtil,
EntityDescriptor ed)
|
|
protected void |
saveRelated(EntityDescriptor ed,
Entity instance,
Connection conn,
DbUtil dbUtil)
|
|
protected void |
saveSingleForeigns(EntityDescriptor ed,
Entity instance,
Connection conn,
DbUtil dbUtil)
|
|
protected void |
saveUnnamedChildren(EntityDescriptor ed,
Entity instance,
Connection conn,
DbUtil dbUtil)
|
|
void |
setDataSource(DataSource dataSource)
|
|
protected
|
truncate(Connection conn,
EntityDescriptor ed,
DbUtil dbUtil)
|
Methods inherited from class de.schwarzrot.data.access.support.AbstractEntityManager |
---|
dumpTypeCache, getApplicationDefaults, getApplicationName, getEntityCache, getEntityIntrospector, getEntityUtils, getName, getSchemaName, getSchemaName, getUserNameProvider, loadClass, needsTransaction, setEntityCache, setEntityIntrospector, setEntityUtils, setSchemaName, setSchemaName, setUserNameProvider |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JDBCEntityManager()
public JDBCEntityManager(DataSource ds)
Method Detail |
---|
public void commit(TransactionResource<?> resource) throws Exception
EntityManager
resource
- - an abstract handle to storage
Exception
- - depends on implementationpublic <E extends Entity> long countInstances(Class<E> entityType, Connection conn)
public TransactionResource<?> createTransactionResource(Transaction t) throws Exception
EntityManager
TransactionResource
is a
wrapper to handle jdbc and preferences the same way.
t
- - the transaction
Exception
- - depends on implementationpublic void execute(TransactionalOperation<?> tao) throws Exception
EntityManager
ApplicationTransaction
tao
- - the transactional operation to execute
Exception
- - depends on implementationpublic final DataSource getDataSource()
public final EntityDescriptor getEntityDescriptor(Class<?> entityType, Connection conn)
public final EntityDescriptor getEntityDescriptor(Class<?> entityType, TransactionResource<?> res)
EntityManager
EntityDescriptor
holds all information needed by an
EntityManager
to handle instances of that entity. The
EntityDescriptor
may vary between different EntityManager
s.
entityType
- - the class of that entityres
- - the wrapped storage handle
public void releaseTransactionResource(TransactionResource<?> resource)
EntityManager
resource
- - a wrapped storage handlepublic void rollback(TransactionResource<?> resource)
EntityManager
Transaction
as
failed.
resource
- - a wrapped storage handlepublic final void setDataSource(DataSource dataSource)
protected <E extends Entity> E checkExistance(E instance, Connection conn, DbUtil dbUtil)
getUniqueColumnNames
E
- the type of the involed entityinstance
- the instance to checkconn
- the connection to persistencedbUtil
- the DbUtil of the connected database
protected int createInstance(Entity instance, Connection conn, DbUtil dbUtil)
protected int find(List<?> resultList, Class<?> entityType, List<ConditionElement> args, EntityDescriptor ed, Connection conn, DbUtil dbUtil, boolean readRelated, Collection<SortInfo> orderSequence)
readProperties
, cause there's no difference between reading the
entire instance or only parts of it.
resultList
- the list, that holds the read entitiesentityType
- the type of entities to readargs
- the list of condition elements, to assemble the where clauseed
- the descriptor of the entityconn
- the connection to databasedbUtil
- the DbUtil instance for the connected databasereadRelated
- flag to signal, whether related entities should be resolved
protected <E extends Entity> E getEntity(E instance, Class<? extends Entity> entityType, long id, Connection conn)
E
- the type of the given instanceinstance
- the instance to read/fillentityType
- the type of the given entityid
- the id of the entity to readconn
- the connection to database
protected long instanceCount(Class<? extends Entity> entityType, List<ConditionElement> args, Connection conn) throws Exception
Exception
protected <E extends Entity> E instanceFromResultSet(ResultSet rs, Connection conn, EntityDescriptor ed, DbUtil dbUtil, boolean readRelated)
protected long queryId(EntityDescriptor ed, Date now, String userName, Connection conn, DbUtil dbUtil)
protected int readProperties(List resultList, Class entityType, Collection<String> properties, List<ConditionElement> args, EntityDescriptor ed, Connection conn, DbUtil dbUtil, int maxRows, boolean readRelated, boolean uniq, Collection<SortInfo> orderSequence)
protected <E extends Entity> int remove(Class<E> entityType, List<ConditionElement> args, EntityDescriptor ed, Connection conn, DbUtil dbUtil) throws Exception
Exception
protected <E extends Entity> int removeChildren(E instance, EntityDescriptor ed, Connection conn, DbUtil dbUtil)
protected <E extends Entity> int removeRelated(Class<?> childEntityType, E instance, Connection conn, DbUtil dbUtil)
protected <E extends Entity> void resolveGroupedUnnamedChildren(E instance, EntityDescriptor ed, PropertyInfo pi, Connection conn, DbUtil dbUtil)
protected <E extends Entity> void resolveNamedChildren(E instance, EntityDescriptor ed, PropertyInfo pi, Connection conn, DbUtil dbUtil)
protected <E extends Entity> void resolveReferences(E instance, EntityDescriptor ed, PropertyInfo pi, Connection conn, DbUtil dbUtil)
protected <E extends Entity> void resolveRelated(EntityDescriptor ed, E instance, Connection conn, DbUtil dbUtil)
Entity
. The
different relations are determined by the EntityDescriptor
and
recognized by the type of the property and the mapping definition for
that property.
E
- the derived type of the entityed
- the descriptor of the entityinstance
- the instance to populateconn
- the active db connectiondbUtil
- the util instance for the target databaseprotected <E extends Entity> void resolveSingleForeign(E instance, EntityDescriptor ed, PropertyInfo pi, Connection conn, DbUtil dbUtil)
protected <E extends Entity> void resolveUnnamedChildren(E instance, EntityDescriptor ed, PropertyInfo pi, Connection conn, DbUtil dbUtil)
protected <E extends Entity> void resolveWeightedReferences(E instance, EntityDescriptor ed, PropertyInfo pi, Connection conn, DbUtil dbUtil)
protected <E extends Entity> int resultSet2EList(ca.odell.glazedlists.EventList<E> resultList, ResultSet rs, Connection conn, EntityDescriptor ed, DbUtil dbUtil, int maxRows, boolean readRelated)
protected <E extends Entity> int resultSet2List(List<E> resultList, ResultSet rs, Connection conn, EntityDescriptor ed, DbUtil dbUtil, int maxRows, boolean readRelated)
protected <E extends Entity> int resultSet2TrList(ca.odell.glazedlists.TransactionList<E> resultList, ResultSet rs, Connection conn, EntityDescriptor ed, DbUtil dbUtil, int maxRows, boolean readRelated)
protected int save(Entity instance, Connection conn, DbUtil dbUtil)
Entity
to persistence. Checks, whether
the instance already exists in persistence, or whether it has to be
created. Saves all related entities as well.
instance
- the entity to saveconn
- the connection to databasedbUtil
- the DbUtil for the connected database
protected void saveForeigns(EntityDescriptor ed, Entity instance, Connection conn, DbUtil dbUtil)
protected int saveInstance(Entity instance, Connection conn, DbUtil dbUtil)
protected void saveNamedChildren(EntityDescriptor ed, Entity instance, Connection conn, DbUtil dbUtil)
protected <E extends Entity> int saveProperties(E instance, Collection<String> propertyNames, List<ConditionElement> args, Connection conn, DbUtil dbUtil, EntityDescriptor ed) throws Exception
Exception
protected void saveRelated(EntityDescriptor ed, Entity instance, Connection conn, DbUtil dbUtil)
protected void saveSingleForeigns(EntityDescriptor ed, Entity instance, Connection conn, DbUtil dbUtil)
protected void saveUnnamedChildren(EntityDescriptor ed, Entity instance, Connection conn, DbUtil dbUtil)
protected <E extends Entity> void truncate(Connection conn, EntityDescriptor ed, DbUtil dbUtil) throws Exception
Exception
|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |