|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ISession
Abstract definition of Session available for the DAO implementation.
The DAO API exposes this interface but it will be automatically adapted
from the underlying JPA-specific implementation (see IAdapter
).
JPA and specific implementations define similar abstractions e.g.
Session vs EntityManager but despite their similarities, their types
actually mismatch making it difficult to provide a generic unified DAO
solution.
Note that this is a subset of the functionality that the underlying
implementation offers. This is the subset required to make the DAO
portable. If required, it is possible to get the underlying
implementation using getDelegate()
Method Summary | ||
---|---|---|
void |
clear()
Clears the Session , removing all cached changes without
applying them. |
|
void |
close()
Closes the Session . |
|
boolean |
contains(Object anEntity)
Returns true if the instance belongs to the current persistence context, false otherwise |
|
IQuery |
createNativeQuery(String aSqlString,
Class<?> aPersistentClass)
Returns instance of JPA implementation-specific Query for executing native SQL queries. |
|
IQuery |
createQuery(String aSqlString)
Returns instance of JPA implementation-specific Query for executing JPA-specific Queries e.g. |
|
|
find(Class<E> aPersistentClass,
Object anId)
Returns the Entity instance if found, null if the entity does not exist |
|
void |
flush()
Flushes the Session by applying all cached changes to the
persistent store. |
|
|
getDelegate()
Returns the implementation-specific Session |
|
ITransaction |
getTransaction()
Returns the ITransaction adapted from the implementation-specific |
|
|
persist(Object anObject)
Returns the Id of the newly persisted Object. |
|
void |
refresh(Object anObject)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any |
|
void |
remove(Object anObject)
Removes Object from the persistent store |
|
void |
update(Object anObject)
Updates the Object in the persistent store |
Method Detail |
---|
void clear() throws DaoException
Session
, removing all cached changes without
applying them. The underlying implementation is JPA implementation-
specific.
DaoException
void close() throws DaoException
Session
. The underlying implementation is JPA
implementation-specific.
DaoException
void flush() throws DaoException
Session
by applying all cached changes to the
persistent store. The underlying implementation is JPA implementation-
specific.
DaoException
boolean contains(Object anEntity)
anEntity
- The entity to check
<E> E find(Class<E> aPersistentClass, Object anId)
E
- aPersistentClass
- Persistent classanId
- The Id to look for
ITransaction getTransaction()
ITransaction
adapted from the implementation-specific
ITransaction
adapted from the implementation-specificIAdapter
void remove(Object anObject)
anObject
- The Object to remove<Id> Id persist(Object anObject)
anObject
- The Object to persist
void update(Object anObject)
anObject
- The Object to updatevoid refresh(Object anObject)
anObject
- The Object to refreshIQuery createQuery(String aSqlString)
aSqlString
- SQL query input
IQuery createNativeQuery(String aSqlString, Class<?> aPersistentClass)
aSql
- SQL query input
<S> S getDelegate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |