|
|||||||||
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(Object[] state,
String[] propertyNames,
String propertyName,
Object propertyValue)
assign a property in hibernates arrays of states |
static void |
attachParams(PreparedStatement statement,
Object params)
Attach params for a prepared statement. |
static void |
closeQuietly(Connection connection)
close a connection null safe and dont throw exception |
static void |
closeQuietly(PreparedStatement preparedStatement)
close a prepared statement |
static void |
closeQuietly(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(Statement statement)
close a statement null safe and dont throw exception |
static String |
convertHqlToCountHql(String hql)
convert an hql to a count hql |
static String |
convertToInClause(Collection<String> collection,
HqlQuery scalarable)
convert a collection of strings (no parens) to an in clause |
static String |
convertToInClauseForSqlStatic(Collection<String> collection)
convert a collection of strings (no parens) to an in clause |
static void |
evict(HibernateSession hibernateSession,
Collection<Object> list,
boolean onlyEvictIfNotNew)
evict a list of objects from hibernate. |
static void |
evict(HibernateSession hibernateSession,
Object object,
boolean onlyEvictIfNotNew)
evict a list of objects from hibernate. |
static org.hibernate.type.Type |
hibernateType(Object o)
Returns a Hibernate Type for the given java type. |
static List<org.hibernate.type.Type> |
hibernateTypes(List<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(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(List<org.hibernate.criterion.Criterion> criterions)
make a list of criterions. |
static List<Object> |
listObject(Object object)
convert an object to a list of objects |
static int |
propertyIndex(String[] propertyNames,
String propertyName)
find the property index based on property name |
static Object |
propertyValue(Object[] state,
String[] propertyNames,
String propertyName)
find a property value in hibernates arrays of states |
static void |
rollbackQuietly(Connection connection)
rollback a connection quietly |
static void |
rollbackQuietly(org.hibernate.Transaction transaction)
rollback a transaction quietly |
static String |
secondLevelCacheRegion(String cacheRegion,
QueryOptions queryOptions)
|
static boolean |
secondLevelCaching(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 boolean secondLevelCaching(Boolean cacheable, QueryOptions queryOptions)
cacheable
- queryOptions
-
public static String secondLevelCacheRegion(String cacheRegion, QueryOptions queryOptions)
cacheRegion
- queryOptions
-
public static String convertHqlToCountHql(String hql)
hql
-
public static void closeQuietly(org.hibernate.ScrollableResults scrollableResults)
scrollableResults
- public static int propertyIndex(String[] propertyNames, String propertyName)
propertyNames
- propertyName
- e.g. userId
public static void assignProperty(Object[] state, String[] propertyNames, String propertyName, Object propertyValue)
state
- propertyNames
- propertyName
- propertyValue
- public static Object propertyValue(Object[] state, String[] propertyNames, String propertyName)
state
- propertyNames
- propertyName
-
public static void closeQuietly(PreparedStatement preparedStatement)
preparedStatement
- public static void evict(HibernateSession hibernateSession, 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, Collection<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(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(List<org.hibernate.criterion.Criterion> criterions)
criterions
-
public static void closeQuietly(Connection connection)
connection
- public static void closeQuietly(ResultSet resultSet)
resultSet
- public static void closeQuietly(org.hibernate.Session session)
session
- public static void closeQuietly(Statement statement)
statement
- public static void rollbackQuietly(Connection connection)
connection
- public static void rollbackQuietly(org.hibernate.Transaction transaction)
transaction
- public static void attachParams(PreparedStatement statement, Object params) throws org.hibernate.HibernateException, SQLException
statement
- params
- either null, Object, Object[], or List of Objects
org.hibernate.HibernateException
SQLException
public static List<Object> listObject(Object object)
object
-
public static org.hibernate.type.Type hibernateType(Object o)
o
- is the object to find the Type for.
public static List<org.hibernate.type.Type> hibernateTypes(List<Object> params)
params
- are the objects to get the types for. Can be list, Object, or array.
public static String convertToInClause(Collection<String> collection, HqlQuery scalarable)
collection
- scalarable
- to set the string
public static String convertToInClauseForSqlStatic(Collection<String> collection)
collection
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |