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

    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • 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 object
      object - a transient instance of a persistent class
      id - 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 object
      query - the query string
      values - 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 object
      queryString - the query string
      value - 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 object
      queryString - the query string
      values - an array of values to be bound to the parameters
      types - 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 SQL
      returnAliases - an array of table aliases that appear inside {} in the SQL string
      returnClasses - the returned persistent classes