Class SessionHelper
- java.lang.Object
-
- com.atlassian.confluence.core.persistence.hibernate.SessionHelper
-
public final class SessionHelper extends Object
Provides utility methods for invoking Session objects using hibernate v2 method signatures, that have since been removed.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.hibernate.query.NativeQuery
createNativeQuery(org.hibernate.Session session, String sql, String[] returnAliases, Class[] returnClasses)
Create a new instance of Query for the given SQL string.static org.hibernate.query.Query
createQuery(org.hibernate.Session session, String queryString, Object[] values, org.hibernate.type.Type[] types)
Create a new instance of Query for the given query string and bind parameters.static org.hibernate.query.Query
createQuery(org.hibernate.Session session, String queryString, Object value, org.hibernate.type.Type type)
Create a new instance of Query for the given query string and bind parameter.static int
delete(org.hibernate.Session session, String query, Object[] values, org.hibernate.type.Type[] types)
Delete all objects returned by the query.static void
save(org.hibernate.Session session, Object object, Serializable id)
Persist the given transient instance, using the given identifier.
-
-
-
Method Detail
-
save
public static void save(org.hibernate.Session session, Object object, Serializable id) throws org.hibernate.HibernateException
Persist the given transient instance, using the given identifier.- Parameters:
session
- the Session objectobject
- a transient instance of a persistent classid
- an unused valid identifier- Throws:
org.hibernate.HibernateException
- when the entity could not be saved
-
delete
public static int delete(org.hibernate.Session session, String query, Object[] values, org.hibernate.type.Type[] types) throws org.hibernate.HibernateException
Delete all objects returned by the query. Return the number of objects deleted.- Parameters:
session
- the Session objectquery
- the query stringvalues
- a list of values to be written to parameters in the query.types
- a list of Hibernate types of the values- Returns:
- the number of instances deleted
- Throws:
org.hibernate.HibernateException
- when the entities could not be deleted
-
createQuery
public static org.hibernate.query.Query createQuery(org.hibernate.Session session, String queryString, Object value, org.hibernate.type.Type type) throws org.hibernate.HibernateException
Create a new instance of Query for the given query string and bind parameter.Bind a value to a parameter in the query string.
- Parameters:
session
- the Session objectqueryString
- the query stringvalue
- a value to be bound to a placeholder (JDBC IN parameter).type
- the Hibernate type of the value- Returns:
- Query
- Throws:
org.hibernate.HibernateException
- when the query could not be created
-
createQuery
public static org.hibernate.query.Query createQuery(org.hibernate.Session session, String queryString, Object[] values, org.hibernate.type.Type[] types) throws org.hibernate.HibernateException
Create a new instance of Query for the given query string and bind parameters.Binding an array of values to parameters in the query string.
- Parameters:
session
- the Session objectqueryString
- the query stringvalues
- an array of values to be bound to the parameterstypes
- an array of Hibernate types of the values- Returns:
- Query
- Throws:
org.hibernate.HibernateException
- when the query could not be created
-
createNativeQuery
public static org.hibernate.query.NativeQuery createNativeQuery(org.hibernate.Session session, String sql, String[] returnAliases, Class[] returnClasses)
Create a new instance of Query for the given SQL string.- Parameters:
sql
- a query expressed in SQLreturnAliases
- an array of table aliases that appear inside {} in the SQL stringreturnClasses
- the returned persistent classes
-
-