public class HibernateUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
escapeSqlWildcards(String oldString,
Connection connection)
Escapes all sql wildcards in the given string, returns the same string if it doesn't contain
any sql wildcards
|
static String |
escapeSqlWildcards(String oldString,
org.hibernate.SessionFactory sessionFactory) |
static <AT extends AttributeType> |
getAttributePredicate(javax.persistence.criteria.CriteriaBuilder cb,
javax.persistence.criteria.Root<Location> locationRoot,
Map<AT,String> serializedAttributeValues)
Constructs a list of predicates for attribute value criteria for use in a JPA Criteria query.
|
static org.hibernate.dialect.Dialect |
getDialect(org.hibernate.SessionFactory sessionFactory)
Fetch the current Dialect of the given SessionFactory
|
static <T> T |
getRealObjectFromProxy(T persistentObject)
Gets an object as an instance of its persistent type if it is a hibernate proxy otherwise
returns the same passed in object
|
static <T> org.hibernate.ScrollableResults |
getScrollableResult(org.hibernate.SessionFactory sessionFactory,
Class<T> type,
int fetchSize)
Creates a ScrollableResults instance for the given entity type with the specified fetch size.
|
static <T> T |
getUniqueEntityByUUID(org.hibernate.SessionFactory sessionFactory,
Class<T> entityClass,
String uuid)
Retrieves a unique entity by its UUID.
|
static boolean |
isHSQLDialect(org.hibernate.SessionFactory sessionFactory)
Check and cache whether the currect dialect is HSQL or not.
|
static boolean |
isPostgreSQLDialect(org.hibernate.SessionFactory sessionFactory)
Check and cache whether the currect dialect is PostgreSQL or not.
|
public static boolean isHSQLDialect(org.hibernate.SessionFactory sessionFactory)
sessionFactory - public static boolean isPostgreSQLDialect(org.hibernate.SessionFactory sessionFactory)
sessionFactory - public static org.hibernate.dialect.Dialect getDialect(org.hibernate.SessionFactory sessionFactory)
sessionFactory - SessionFactory to pull the dialect frompublic static String escapeSqlWildcards(String oldString, org.hibernate.SessionFactory sessionFactory)
escapeSqlWildcards(String, Connection)public static String escapeSqlWildcards(String oldString, Connection connection)
oldString - the string in which to escape the sql wildcardsconnection - The underlying database connectionpublic static <AT extends AttributeType> List<javax.persistence.criteria.Predicate> getAttributePredicate(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.Root<Location> locationRoot, Map<AT,String> serializedAttributeValues)
AT - The type of the attributecb - The CriteriaBuilder used to construct the CriteriaQuerylocationRoot - The root of the CriteriaQuery for the Location entityserializedAttributeValues - A map of AttributeType to serialized attribute valuespublic static <T> T getRealObjectFromProxy(T persistentObject)
persistentObject - the object to unproxypublic static <T> T getUniqueEntityByUUID(org.hibernate.SessionFactory sessionFactory,
Class<T> entityClass,
String uuid)
throws DAOException
sessionFactory - the session factory to create sessions.entityClass - the class of the entity to retrieve.uuid - the UUID of the entity.DAOException - if there's an issue in data access.public static <T> org.hibernate.ScrollableResults getScrollableResult(org.hibernate.SessionFactory sessionFactory,
Class<T> type,
int fetchSize)
sessionFactory - the session factory to create sessions.type - the class type of the entity for which the ScrollableResults is created.fetchSize - the number of rows to fetch in a batch.Copyright © 2024 OpenMRS Inc.. All rights reserved.