|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.fiveamsolutions.nci.commons.util.HibernateHelper
com.fiveamsolutions.nci.commons.util.CsmEnabledHibernateHelper
gov.nih.nci.caarray.util.CaArrayHibernateHelperImpl
public final class CaArrayHibernateHelperImpl
Utility class to create and retrieve Hibernate sessions. Most methods are pass-throughs to HibernateHelper
,
except for the methods involving filters.
Field Summary |
---|
Fields inherited from class com.fiveamsolutions.nci.commons.util.HibernateHelper |
---|
MAX_IN_CLAUSE_LENGTH |
Method Summary | |
---|---|
java.lang.String |
buildInClauses(java.util.List<? extends java.io.Serializable> items,
java.lang.String columnName,
java.util.Map<java.lang.String,java.util.List<? extends java.io.Serializable>> blocks)
Break up a list of items into separate in clauses, to avoid limits imposed by databases or by Hibernate bug http://opensource.atlassian.com/projects/hibernate/browse/HHH-2166. |
static CaArrayHibernateHelper |
create()
|
void |
disableFilters()
Disable security filters on the current session. |
java.lang.Object |
doUnfiltered(UnfilteredCallback uc)
Do something in an unfiltered session. |
org.hibernate.Session |
getCurrentSession()
Returns the current Hibernate session. |
java.sql.Connection |
getNewConnection()
|
void |
initialize()
Because of circular references (for instance, SecurityUtils references this object through the static factory), we must use a two stage construction/initialization process. |
void |
openAndBindSession()
Open a hibernate session and bind it as the current session via org.hibernate.context.ManagedSessionContext#bind(org.hibernate.classic.Session) . |
void |
setFiltersEnabled(boolean enable)
Set whether security filters should be enabled for the next session returned from getCurrentSession(). |
void |
setQueryParams(java.util.Map<java.lang.String,java.lang.Object> params,
org.hibernate.Query q)
Sets the named parameters in the given query from the given map. |
java.lang.Object |
unwrapProxy(java.lang.Object entity)
If entity is a hibernate proxy, return the actual object it proxies, otherwise return the entity itself. |
Methods inherited from class com.fiveamsolutions.nci.commons.util.CsmEnabledHibernateHelper |
---|
initializeConfig, modifyConfig, reinitializeCsmFilters, setSecurity |
Methods inherited from class com.fiveamsolutions.nci.commons.util.HibernateHelper |
---|
beginTransaction, bindInClauseParameters, buildInClause, buildSessionFactory, getConfiguration, getSessionFactory, isManagedSession, openAndBindSession, rollbackTransaction, unbindAndCleanupSession, unbindAndCleanupSession |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface gov.nih.nci.caarray.util.CaArrayHibernateHelper |
---|
beginTransaction, getConfiguration, getSessionFactory, rollbackTransaction, unbindAndCleanupSession |
Method Detail |
---|
public static CaArrayHibernateHelper create()
public void initialize()
initialize
in class com.fiveamsolutions.nci.commons.util.HibernateHelper
public org.hibernate.Session getCurrentSession()
getCurrentSession
in interface CaArrayHibernateHelper
getCurrentSession
in class com.fiveamsolutions.nci.commons.util.HibernateHelper
HibernateHelper#getCurrentSession()
public void setFiltersEnabled(boolean enable)
setFiltersEnabled
in interface CaArrayHibernateHelper
enable
- whether the filters should be enabled.public void openAndBindSession()
org.hibernate.context.ManagedSessionContext#bind(org.hibernate.classic.Session)
. The hibernate property
"hibernate.current_session_context_class" must be set to "managed" for this to have effect This method should be
called from within an Interceptor or Filter type class that is setting up the scope of the Session. This method
should then call CaArrayHibernateHelper.unbindAndCleanupSession()
when the scope of the Session is
expired.
Clears the SecurityInterceptor.
openAndBindSession
in interface CaArrayHibernateHelper
openAndBindSession
in class com.fiveamsolutions.nci.commons.util.HibernateHelper
HibernateHelper#openAndBindSession()
public java.sql.Connection getNewConnection() throws java.sql.SQLException
getNewConnection
in interface CaArrayHibernateHelper
java.sql.SQLException
- if an error occurs obtaining the connectionpublic java.lang.Object doUnfiltered(UnfilteredCallback uc)
doUnfiltered
in interface CaArrayHibernateHelper
uc
- callback class
public void disableFilters()
disableFilters
in interface CaArrayHibernateHelper
public void setQueryParams(java.util.Map<java.lang.String,java.lang.Object> params, org.hibernate.Query q)
setQueryParams
in interface CaArrayHibernateHelper
params
- map of parameter name -> value(s) for that named parameter.q
- the querypublic java.lang.String buildInClauses(java.util.List<? extends java.io.Serializable> items, java.lang.String columnName, java.util.Map<java.lang.String,java.util.List<? extends java.io.Serializable>> blocks)
buildInClauses
in interface CaArrayHibernateHelper
items
- list of items to include in the in clausecolumnName
- name of column to match against the listblocks
- empty Map of HQL param name to param list of values to be set in the HQL query - it will be
populated by the method
public java.lang.Object unwrapProxy(java.lang.Object entity)
unwrapProxy
in interface CaArrayHibernateHelper
entity
- the object to unwrap (if it is a proxy)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |