Interface HibSession
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
HibSessionImpl
public interface HibSession extends Serializable
Interface to do hibernate interactions.- Author:
- Mike Douglass douglm at rpi.edu
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbeginTransaction()Begin a transactionvoidcacheableQuery()Mark the query as cacheablevoidclear()Clear a sessionvoidclose()voidcommit()Commit a transactionorg.hibernate.CriteriacreateCriteria(Class<?> cl)Create a Criteria ready for the additon of Criterion.voidcreateNoFlushQuery(String s)Create a query ready for parameter replacement or execution and flag it for no flush.voidcreateQuery(String s)Create a query ready for parameter replacement or execution.voidcreateSQLQuery(String s, String returnAlias, Class<?> returnClass)Create a sql query ready for parameter replacement or execution.voiddelete(Object obj)Delete an objectvoiddisconnect()Disconnect a sessionvoidevict(Object val)Evict an object from the session.intexecuteUpdate()voidflush()Objectget(Class cl, int id)Return an object of the given class with the given id if it is already associated with this session.Objectget(Class cl, Serializable id)Return an object of the given class with the given id if it is already associated with this session.ListgetList()Return a list resulting from the query.StringgetQueryString()org.hibernate.SessiongetSession()ObjectgetUnique()Return the single object resulting from the query.voidinit(org.hibernate.SessionFactory sessFactory)Set up for a hibernate interaction.booleanisOpen()voidlockRead(Object o)voidlockUpdate(Object o)Objectmerge(Object obj)Merge and update an object which may have been loaded in a previous hibernate sessionvoidnamedQuery(String name)Create a named query ready for parameter replacement or execution.voidreAttach(UnversionedDbentity<?> val)voidrestore(Object obj)Save a new object with the given id.voidrollback()Rollback a transactionbooleanrolledback()Did we rollback the transaction?voidsave(Object obj)Save a new object.voidsaveOrUpdate(Object obj)Save a new object or update an object which may have been loaded in a previous hibernate sessionObjectsaveOrUpdateCopy(Object obj)Copy the state of the given object onto the persistent object with the same identifier.voidsetBool(String parName, boolean parVal)Set the named parameter with the given valuevoidsetDate(String parName, Date parVal)Set the named parameter with the given valuevoidsetEntity(String parName, Object parVal)Set the named parameter with the given valuevoidsetFirstResult(int val)Set the first result for a paged batchvoidsetFlushMode(org.hibernate.FlushMode val)set the flushmodevoidsetInt(String parName, int parVal)Set the named parameter with the given valuevoidsetLong(String parName, long parVal)Set the named parameter with the given valuevoidsetMaxResults(int val)Set the max number of results for a paged batchvoidsetParameter(String parName, Object parVal)Set the named parameter with the given valuevoidsetParameterList(String parName, Collection<?> parVal)Set the named parameter with the given CollectionvoidsetString(String parName, String parVal)Set the named parameter with the given valuebooleantransactionStarted()Return true if we have a transaction startedvoidupdate(Object obj)Update an object which may have been loaded in a previous hibernate session
-
-
-
Method Detail
-
init
void init(org.hibernate.SessionFactory sessFactory) throws org.bedework.webdav.servlet.shared.WebdavException
Set up for a hibernate interaction. Throw the object away on exception.- Parameters:
sessFactory-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
getSession
org.hibernate.Session getSession() throws org.bedework.webdav.servlet.shared.WebdavException- Returns:
- Session
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
isOpen
boolean isOpen() throws org.bedework.webdav.servlet.shared.WebdavException- Returns:
- boolean true if open
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
clear
void clear() throws org.bedework.webdav.servlet.shared.WebdavExceptionClear a session- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
disconnect
void disconnect() throws org.bedework.webdav.servlet.shared.WebdavExceptionDisconnect a session- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setFlushMode
void setFlushMode(org.hibernate.FlushMode val) throws org.bedework.webdav.servlet.shared.WebdavExceptionset the flushmode- Parameters:
val-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
beginTransaction
void beginTransaction() throws org.bedework.webdav.servlet.shared.WebdavExceptionBegin a transaction- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
transactionStarted
boolean transactionStarted()
Return true if we have a transaction started- Returns:
- boolean
-
commit
void commit() throws org.bedework.webdav.servlet.shared.WebdavExceptionCommit a transaction- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
rollback
void rollback() throws org.bedework.webdav.servlet.shared.WebdavExceptionRollback a transaction- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
rolledback
boolean rolledback() throws org.bedework.webdav.servlet.shared.WebdavExceptionDid we rollback the transaction?- Returns:
- boolean
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
createCriteria
org.hibernate.Criteria createCriteria(Class<?> cl) throws org.bedework.webdav.servlet.shared.WebdavException
Create a Criteria ready for the additon of Criterion.- Parameters:
cl- Class for criteria- Returns:
- Criteria created Criteria
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
evict
void evict(Object val) throws org.bedework.webdav.servlet.shared.WebdavException
Evict an object from the session.- Parameters:
val- Object to evict- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
createQuery
void createQuery(String s) throws org.bedework.webdav.servlet.shared.WebdavException
Create a query ready for parameter replacement or execution.- Parameters:
s- String hibernate query- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
createNoFlushQuery
void createNoFlushQuery(String s) throws org.bedework.webdav.servlet.shared.WebdavException
Create a query ready for parameter replacement or execution and flag it for no flush. This assumes that any queued changes will not affect the result of the query.- Parameters:
s- String hibernate query- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
getQueryString
String getQueryString() throws org.bedework.webdav.servlet.shared.WebdavException
- Returns:
- query string
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
createSQLQuery
void createSQLQuery(String s, String returnAlias, Class<?> returnClass) throws org.bedework.webdav.servlet.shared.WebdavException
Create a sql query ready for parameter replacement or execution.- Parameters:
s- String hibernate queryreturnAlias-returnClass-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
namedQuery
void namedQuery(String name) throws org.bedework.webdav.servlet.shared.WebdavException
Create a named query ready for parameter replacement or execution.- Parameters:
name- String named query name- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
cacheableQuery
void cacheableQuery() throws org.bedework.webdav.servlet.shared.WebdavExceptionMark the query as cacheable- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setString
void setString(String parName, String parVal) throws org.bedework.webdav.servlet.shared.WebdavException
Set the named parameter with the given value- Parameters:
parName- String parameter nameparVal- String parameter value- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setDate
void setDate(String parName, Date parVal) throws org.bedework.webdav.servlet.shared.WebdavException
Set the named parameter with the given value- Parameters:
parName- String parameter nameparVal- Date parameter value- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setBool
void setBool(String parName, boolean parVal) throws org.bedework.webdav.servlet.shared.WebdavException
Set the named parameter with the given value- Parameters:
parName- String parameter nameparVal- boolean parameter value- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setInt
void setInt(String parName, int parVal) throws org.bedework.webdav.servlet.shared.WebdavException
Set the named parameter with the given value- Parameters:
parName- String parameter nameparVal- int parameter value- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setLong
void setLong(String parName, long parVal) throws org.bedework.webdav.servlet.shared.WebdavException
Set the named parameter with the given value- Parameters:
parName- String parameter nameparVal- long parameter value- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setEntity
void setEntity(String parName, Object parVal) throws org.bedework.webdav.servlet.shared.WebdavException
Set the named parameter with the given value- Parameters:
parName- String parameter nameparVal- Object parameter value- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setParameter
void setParameter(String parName, Object parVal) throws org.bedework.webdav.servlet.shared.WebdavException
Set the named parameter with the given value- Parameters:
parName- String parameter nameparVal- Object parameter value- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setParameterList
void setParameterList(String parName, Collection<?> parVal) throws org.bedework.webdav.servlet.shared.WebdavException
Set the named parameter with the given Collection- Parameters:
parName- String parameter nameparVal- Collection parameter value- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setFirstResult
void setFirstResult(int val) throws org.bedework.webdav.servlet.shared.WebdavExceptionSet the first result for a paged batch- Parameters:
val- int first index- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
setMaxResults
void setMaxResults(int val) throws org.bedework.webdav.servlet.shared.WebdavExceptionSet the max number of results for a paged batch- Parameters:
val- int max number- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
getUnique
Object getUnique() throws org.bedework.webdav.servlet.shared.WebdavException
Return the single object resulting from the query.- Returns:
- Object retrieved object or null
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
getList
List getList() throws org.bedework.webdav.servlet.shared.WebdavException
Return a list resulting from the query.- Returns:
- List list from query
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
executeUpdate
int executeUpdate() throws org.bedework.webdav.servlet.shared.WebdavException- Returns:
- int number updated
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
update
void update(Object obj) throws org.bedework.webdav.servlet.shared.WebdavException
Update an object which may have been loaded in a previous hibernate session- Parameters:
obj-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
merge
Object merge(Object obj) throws org.bedework.webdav.servlet.shared.WebdavException
Merge and update an object which may have been loaded in a previous hibernate session- Parameters:
obj-- Returns:
- Object the persiatent object
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
saveOrUpdate
void saveOrUpdate(Object obj) throws org.bedework.webdav.servlet.shared.WebdavException
Save a new object or update an object which may have been loaded in a previous hibernate session- Parameters:
obj-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
saveOrUpdateCopy
Object saveOrUpdateCopy(Object obj) throws org.bedework.webdav.servlet.shared.WebdavException
Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.- Parameters:
obj-- Returns:
- Object
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
get
Object get(Class cl, Serializable id) throws org.bedework.webdav.servlet.shared.WebdavException
Return an object of the given class with the given id if it is already associated with this session. This must be called for specific key queries or we can get a NonUniqueObjectException later.- Parameters:
cl- Class of the instanceid- A serializable key- Returns:
- Object
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
get
Object get(Class cl, int id) throws org.bedework.webdav.servlet.shared.WebdavException
Return an object of the given class with the given id if it is already associated with this session. This must be called for specific key queries or we can get a NonUniqueObjectException later.- Parameters:
cl- Class of the instanceid- int key- Returns:
- Object
- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
save
void save(Object obj) throws org.bedework.webdav.servlet.shared.WebdavException
Save a new object.- Parameters:
obj-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
delete
void delete(Object obj) throws org.bedework.webdav.servlet.shared.WebdavException
Delete an object- Parameters:
obj-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
restore
void restore(Object obj) throws org.bedework.webdav.servlet.shared.WebdavException
Save a new object with the given id. This should only be used for restoring the db from a save.- Parameters:
obj-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
reAttach
void reAttach(UnversionedDbentity<?> val) throws org.bedework.webdav.servlet.shared.WebdavException
- Parameters:
val-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
lockRead
void lockRead(Object o) throws org.bedework.webdav.servlet.shared.WebdavException
- Parameters:
o-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
lockUpdate
void lockUpdate(Object o) throws org.bedework.webdav.servlet.shared.WebdavException
- Parameters:
o-- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
flush
void flush() throws org.bedework.webdav.servlet.shared.WebdavException- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
close
void close() throws org.bedework.webdav.servlet.shared.WebdavException- Throws:
org.bedework.webdav.servlet.shared.WebdavException
-
-