public class HibernateSession extends Object
Hibernate helper class. These are kept in a threadlocal to keep transactions going smoothly. If you are in a nested callback situation, and in the same transaction, then the HibernateSession instance will be different, but the underlying Session (from hibernate) object will be the same. To get an instanceof HibernateSession, use the callbackHibernateSession inverse of control method.
Modifier and Type | Method and Description |
---|---|
static void |
_internal_closeAllHibernateSessions(Throwable t)
close all sessions, but dont throw errors, based on throwable
|
static HibernateSession |
_internal_hibernateSession()
get the current hibernate session.
|
static HibernateSession |
_internal_hibernateSession(GrouperTransactionType grouperTransactionType)
dont call this method unless you know what you are doing
|
static void |
_internal_hibernateSessionCatch(HibernateSession hibernateSession,
Throwable e)
catch and handle an exception while working with hibernate session.
|
static void |
_internal_hibernateSessionEnd(HibernateSession hibernateSession)
end a hibernate session.
|
static boolean |
_internal_hibernateSessionFinally(HibernateSession hibernateSession)
finally block from hibernate session (dont call unless you know what you are doing
|
static Set<HibernateSession> |
_internal_staticSessions()
this is for internal purposes only, dont use this unless you know what you are doing
|
static void |
assertNotGrouperReadonly()
make sure not readonly mode
|
static ByCriteriaStatic |
byCriteriaStatic()
do a criteria query with proper error handling and in an enclosing transaction
(if applicable), or a new one if not
|
ByHql |
byHql()
hql action for hibernate
|
static ByHqlStatic |
byHqlStatic()
do a hql query with proper error handling and in an enclosing transaction
(if applicable), or a new one if not
|
ByObject |
byObject() |
static ByObjectStatic |
byObjectStatic()
do an object operation
with proper error handling and in an enclosing transaction
(if applicable), or a new one if not
|
BySql |
bySql()
hql action for hibernate
|
static BySqlStatic |
bySqlStatic()
do a sql query with proper error handling and in an enclosing transaction
(if applicable), or a new one if not
|
static Object |
callbackHibernateSession(GrouperTransactionType grouperTransactionType,
AuditControl auditControl,
HibernateHandler hibernateHandler)
call this to send a callback for the hibernate session object.
|
boolean |
commit(GrouperCommitType grouperCommitType)
commit (perhaps, depending on type)
|
GrouperTransactionType |
getGrouperTransactionType()
this will return the underlying (if exist) transaction type, and if not,
then the one this was constructed with
|
org.hibernate.Session |
getSession()
hibernate session object can be accessed by user.
|
static void |
internal_assignThreadlocalReadonly(Boolean internal_threadlocalReadonly) |
static Boolean |
internal_retrieveThreadlocalReadonly() |
boolean |
isCachingEnabled()
provide ability to turn off all caching for this session
|
boolean |
isNewHibernateSession()
see if this is a new hibernate session
|
boolean |
isReadonly()
if this is readonly (based on this declaration or underlying)
|
static boolean |
isReadonlyMode()
if readonly by threadlocal or config param
|
boolean |
isTransactionActive()
see if tx is active (not committed or rolled back, see Hibernate transaction
if there is no transaction, it will return false
|
HibernateMisc |
misc()
misc actions for hibernate session
|
static void |
resetAllThreadLocals()
call this at the end of requests to make sure everything is cleared out or
call periodically...
|
boolean |
rollback(GrouperRollbackType grouperRollbackType)
rollback (perhaps, depending on type)
|
void |
setCachingEnabled(boolean enabledCaching1)
provide ability to turn off all caching for this session
|
static void |
threadLocalReadonlyAssign()
assign that grouper is in readonly mode, make sure to call clear in a finally block
|
static void |
threadLocalReadonlyClear()
in finally block call this to not make grouper readonly anymore
|
String |
toString()
descriptive toString for error handling
|
public ByObject byObject()
public static Boolean internal_retrieveThreadlocalReadonly()
public static void internal_assignThreadlocalReadonly(Boolean internal_threadlocalReadonly)
internal_threadlocalReadonly
- the internal_threadlocalReadonly to setpublic static boolean isReadonlyMode()
public static void threadLocalReadonlyAssign()
public static void threadLocalReadonlyClear()
public boolean isCachingEnabled()
public void setCachingEnabled(boolean enabledCaching1)
enabledCaching1
- the enabledCaching to setpublic static Set<HibernateSession> _internal_staticSessions()
public static void resetAllThreadLocals()
public static HibernateSession _internal_hibernateSession()
public static void _internal_closeAllHibernateSessions(Throwable t)
t
- public static HibernateSession _internal_hibernateSession(GrouperTransactionType grouperTransactionType) throws GrouperDAOException
grouperTransactionType
- GrouperDAOException
public static void _internal_hibernateSessionEnd(HibernateSession hibernateSession) throws SQLException
hibernateSession
- SQLException
public static void assertNotGrouperReadonly()
public static void _internal_hibernateSessionCatch(HibernateSession hibernateSession, Throwable e) throws GrouperDAOException
hibernateSession
- e
- GrouperDAOException
public static boolean _internal_hibernateSessionFinally(HibernateSession hibernateSession)
hibernateSession
- public static Object callbackHibernateSession(GrouperTransactionType grouperTransactionType, AuditControl auditControl, HibernateHandler hibernateHandler) throws GrouperDAOException
grouperTransactionType
- is enum of how the transaction should work.auditControl
- WILL_AUDIT if caller will create an audit record, WILL_NOT_AUDIT if nothibernateHandler
- will get the callbackGrouperDAOException
- if there is a problem, will preserve runtime exceptions so they are
thrown to the callerpublic static ByHqlStatic byHqlStatic()
public static BySqlStatic bySqlStatic()
public static ByCriteriaStatic byCriteriaStatic()
public static ByObjectStatic byObjectStatic()
public String toString()
public org.hibernate.Session getSession()
public HibernateMisc misc()
public ByHql byHql()
public BySql bySql()
public boolean isNewHibernateSession()
public boolean isReadonly()
public GrouperTransactionType getGrouperTransactionType()
public boolean commit(GrouperCommitType grouperCommitType)
grouperCommitType
- is type of commitpublic boolean isTransactionActive()
public boolean rollback(GrouperRollbackType grouperRollbackType)
grouperRollbackType
- is type of rollbackCopyright © 2016 Internet2. All rights reserved.