|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.internet2.middleware.grouper.hibernate.HibUtils
public class HibUtils
Constructor Summary | |
---|---|
HibUtils()
|
Method Summary | |
---|---|
static void |
assignProperty(java.lang.Object[] state,
java.lang.String[] propertyNames,
java.lang.String propertyName,
java.lang.Object propertyValue)
assign a property in hibernates arrays of states |
static void |
attachParams(java.sql.PreparedStatement statement,
java.lang.Object params)
Attach params for a prepared statement. |
static void |
closeQuietly(java.sql.Connection connection)
close a connection null safe and dont throw exception |
static void |
closeQuietly(java.sql.PreparedStatement preparedStatement)
close a prepared statement |
static void |
closeQuietly(java.sql.ResultSet resultSet)
close a resultSet null safe and dont throw exception |
static void |
closeQuietly(org.hibernate.ScrollableResults scrollableResults)
|
static void |
closeQuietly(org.hibernate.Session session)
close a session null safe and dont throw exception |
static void |
closeQuietly(java.sql.Statement statement)
close a statement null safe and dont throw exception |
static void |
convertFieldsToSqlInString(java.util.Collection<Field> fields,
HqlQuery hqlQuery,
java.lang.StringBuilder sql,
java.lang.String fieldColumnName)
|
static java.lang.String |
convertHqlToCountHql(java.lang.String hql)
convert an hql to a count hql |
static java.lang.String |
convertSourcesToSqlInString(java.util.Set<edu.internet2.middleware.subject.Source> sources)
e.g. |
static void |
convertSourcesToSqlInString(java.util.Set<edu.internet2.middleware.subject.Source> sources,
HqlQuery hqlQuery,
java.lang.StringBuilder sql,
java.lang.String sourceColumnName)
|
static java.lang.String |
convertToInClause(java.util.Collection<java.lang.String> collection,
HqlQuery scalarable)
convert a collection of strings (no parens) to an in clause |
static java.lang.String |
convertToInClauseForSqlStatic(java.util.Collection<java.lang.String> collection)
convert a collection of strings (no parens) to an in clause |
static void |
convertToMultiKeyInClause(java.util.Collection<org.apache.commons.collections.keyvalue.MultiKey> collection,
HqlQuery scalarable,
java.util.Collection<java.lang.String> columnNames,
java.lang.StringBuilder whereClause)
convert a collection of multikeys to an in clause with multiple args. |
static java.lang.String |
convertToSubjectInClause(java.util.Collection<edu.internet2.middleware.subject.Subject> subjects,
HqlQuery hqlQuery,
java.lang.String memberAlias)
|
static java.lang.String |
equalsOrIs(java.lang.Object value,
java.lang.String bindVar)
if in an hql or sql query, depending on the value, pass is or = back |
static java.lang.String |
escapeSqlString(java.lang.String input)
escape the quotes from sql string |
static void |
evict(HibernateSession hibernateSession,
java.util.Collection<java.lang.Object> list,
boolean onlyEvictIfNotNew)
evict a list of objects from hibernate. |
static void |
evict(HibernateSession hibernateSession,
java.lang.Object object,
boolean onlyEvictIfNotNew)
evict a list of objects from hibernate. |
static void |
evict(HibernateSession hibernateSession,
java.lang.Object object,
boolean onlyEvictIfNotNew,
boolean evictBeforeFlush)
evict a list of objects from hibernate. |
static org.hibernate.type.Type |
hibernateType(java.lang.Object o)
Returns a Hibernate Type for the given java type. |
static java.util.List<org.hibernate.type.Type> |
hibernateTypes(java.util.List<java.lang.Object> params)
Returns a list of Hibernate types corresponding to the given params. |
static org.hibernate.criterion.Criterion |
listCrit(org.hibernate.criterion.Criterion... criterions)
make a list of criterions. |
static org.hibernate.criterion.Criterion |
listCrit(java.util.List<org.hibernate.criterion.Criterion> criterions)
make a list of criterions. |
static org.hibernate.criterion.Criterion |
listCritOr(org.hibernate.criterion.Criterion... criterions)
make a list of criterions. |
static org.hibernate.criterion.Criterion |
listCritOr(java.util.List<org.hibernate.criterion.Criterion> criterions)
make a list of criterions. |
static java.util.List<java.lang.Object> |
listObject(java.lang.Object object)
convert an object to a list of objects |
static java.lang.String |
paramsToString(java.lang.Object params,
java.lang.Object types)
Convert the params to friendly strings |
static java.lang.String |
parseAlias(java.lang.String text,
boolean exceptionIfNotFound)
Parses an alias out of a sql query. |
static int |
propertyIndex(java.lang.String[] propertyNames,
java.lang.String propertyName)
find the property index based on property name |
static java.lang.Object |
propertyValue(java.lang.Object[] state,
java.lang.String[] propertyNames,
java.lang.String propertyName)
find a property value in hibernates arrays of states |
static void |
rollbackQuietly(java.sql.Connection connection)
rollback a connection quietly |
static void |
rollbackQuietly(org.hibernate.Transaction transaction)
rollback a transaction quietly |
static java.lang.String |
secondLevelCacheRegion(java.lang.String cacheRegion,
QueryOptions queryOptions)
|
static boolean |
secondLevelCaching(java.lang.Boolean cacheable,
QueryOptions queryOptions)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HibUtils()
Method Detail |
---|
public static java.lang.String paramsToString(java.lang.Object params, java.lang.Object types)
params
- types
-
public static java.lang.String parseAlias(java.lang.String text, boolean exceptionIfNotFound)
text
- is the text to find the alias in.exceptionIfNotFound
- if true, when an alias is not found, and exception will be thrown.
public static java.lang.String equalsOrIs(java.lang.Object value, java.lang.String bindVar)
value
- bindVar
-
public static boolean secondLevelCaching(java.lang.Boolean cacheable, QueryOptions queryOptions)
cacheable
- queryOptions
-
public static java.lang.String secondLevelCacheRegion(java.lang.String cacheRegion, QueryOptions queryOptions)
cacheRegion
- queryOptions
-
public static java.lang.String convertHqlToCountHql(java.lang.String hql)
hql
-
public static void closeQuietly(org.hibernate.ScrollableResults scrollableResults)
scrollableResults
- public static int propertyIndex(java.lang.String[] propertyNames, java.lang.String propertyName)
propertyNames
- propertyName
- e.g. userId
public static void assignProperty(java.lang.Object[] state, java.lang.String[] propertyNames, java.lang.String propertyName, java.lang.Object propertyValue)
state
- propertyNames
- propertyName
- propertyValue
- public static java.lang.Object propertyValue(java.lang.Object[] state, java.lang.String[] propertyNames, java.lang.String propertyName)
state
- propertyNames
- propertyName
-
public static void closeQuietly(java.sql.PreparedStatement preparedStatement)
preparedStatement
- public static void evict(HibernateSession hibernateSession, java.lang.Object object, boolean onlyEvictIfNotNew)
evict a list of objects from hibernate. do this always for two reasons: 1. If you edit an object that is in the hibernate session, and commit, it will commit those changes magically. Only objects called session.save(obj) or update etc should be committed 2. If you select an object, then try to store it back (but have a different reference, e.g. if the DTO went through it, then you will get an exception: "a different object with the same identifier value was already associated with the session"
hibernateSession
- grouper hibernateSession, can be null if not knownobject
- to evict that was just retrieved, can be list or arrayonlyEvictIfNotNew
- true to only evict if this is a nested txpublic static void evict(HibernateSession hibernateSession, java.lang.Object object, boolean onlyEvictIfNotNew, boolean evictBeforeFlush)
evict a list of objects from hibernate. do this always for two reasons: 1. If you edit an object that is in the hibernate session, and commit, it will commit those changes magically. Only objects called session.save(obj) or update etc should be committed 2. If you select an object, then try to store it back (but have a different reference, e.g. if the DTO went through it, then you will get an exception: "a different object with the same identifier value was already associated with the session"
hibernateSession
- grouper hibernateSession, can be null if not knownobject
- to evict that was just retrieved, can be list or arrayonlyEvictIfNotNew
- true to only evict if this is a nested txevictBeforeFlush
- if evict before flush (dont do this if iterating through list)public static void evict(HibernateSession hibernateSession, java.util.Collection<java.lang.Object> list, boolean onlyEvictIfNotNew)
evict a list of objects from hibernate. do this always for two reasons: 1. If you edit an object that is in the hibernate session, and commit, it will commit those changes magically. Only objects called session.save(obj) or update etc should be committed 2. If you select an object, then try to store it back (but have a different reference, e.g. if the DTO went through it, then you will get an exception: "a different object with the same identifier value was already associated with the session"
hibernateSession
- grouper hibernateSessionlist
- of objects from hibernate to evictonlyEvictIfNotNew
- true to only evict if this is a nested txpublic static org.hibernate.criterion.Criterion listCrit(org.hibernate.criterion.Criterion... criterions)
criterions
-
public static org.hibernate.criterion.Criterion listCrit(java.util.List<org.hibernate.criterion.Criterion> criterions)
criterions
-
public static org.hibernate.criterion.Criterion listCritOr(org.hibernate.criterion.Criterion... criterions)
criterions
-
public static org.hibernate.criterion.Criterion listCritOr(java.util.List<org.hibernate.criterion.Criterion> criterions)
criterions
-
public static void closeQuietly(java.sql.Connection connection)
connection
- public static void closeQuietly(java.sql.ResultSet resultSet)
resultSet
- public static void closeQuietly(org.hibernate.Session session)
session
- public static void closeQuietly(java.sql.Statement statement)
statement
- public static void rollbackQuietly(java.sql.Connection connection)
connection
- public static void rollbackQuietly(org.hibernate.Transaction transaction)
transaction
- public static void attachParams(java.sql.PreparedStatement statement, java.lang.Object params) throws org.hibernate.HibernateException, java.sql.SQLException
statement
- params
- either null, Object, Object[], or List of Objects
org.hibernate.HibernateException
java.sql.SQLException
public static java.util.List<java.lang.Object> listObject(java.lang.Object object)
object
-
public static org.hibernate.type.Type hibernateType(java.lang.Object o)
o
- is the object to find the Type for.
public static java.util.List<org.hibernate.type.Type> hibernateTypes(java.util.List<java.lang.Object> params)
params
- are the objects to get the types for. Can be list, Object, or array.
public static java.lang.String convertToInClause(java.util.Collection<java.lang.String> collection, HqlQuery scalarable)
collection
- scalarable
- to set the string
public static java.lang.String convertToSubjectInClause(java.util.Collection<edu.internet2.middleware.subject.Subject> subjects, HqlQuery hqlQuery, java.lang.String memberAlias)
memberAlias
- is the alias of the table for members, e.g. gmsubjects
- collection of subjectshqlQuery
- so far
public static java.lang.String escapeSqlString(java.lang.String input)
input
-
public static java.lang.String convertToInClauseForSqlStatic(java.util.Collection<java.lang.String> collection)
collection
-
public static void convertToMultiKeyInClause(java.util.Collection<org.apache.commons.collections.keyvalue.MultiKey> collection, HqlQuery scalarable, java.util.Collection<java.lang.String> columnNames, java.lang.StringBuilder whereClause)
collection
- scalarable
- to set the stringcolumnNames
- names of columns in multikeywhereClause
- public static void convertFieldsToSqlInString(java.util.Collection<Field> fields, HqlQuery hqlQuery, java.lang.StringBuilder sql, java.lang.String fieldColumnName)
fields
- hqlQuery
- sql
- before the and statementfieldColumnName
- public static void convertSourcesToSqlInString(java.util.Set<edu.internet2.middleware.subject.Source> sources, HqlQuery hqlQuery, java.lang.StringBuilder sql, java.lang.String sourceColumnName)
sources
- hqlQuery
- sql
- before the and statementsourceColumnName
- public static java.lang.String convertSourcesToSqlInString(java.util.Set<edu.internet2.middleware.subject.Source> sources)
sources
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |