Class HibernateDaoUtils

java.lang.Object
com.atlassian.bamboo.persistence3.HibernateDaoUtils

public class HibernateDaoUtils extends Object
A variety of methods useful when interacting with DAO objects.
  • Field Details

    • ORACLE_MAXIMUM_NUMBER_OF_VALUES_FOR_IN_QUERY

      public static final int ORACLE_MAXIMUM_NUMBER_OF_VALUES_FOR_IN_QUERY
      See Also:
  • Method Details

    • updateTimestamp

      public static void updateTimestamp(BambooObject bambooObject)
    • copyTimestamp

      public static void copyTimestamp(BambooObject from, BambooObject to)
    • saveOrUpdate

      public static void saveOrUpdate(@NotNull @NotNull org.hibernate.Session session, BambooObject entity)
    • saveOrUpdateAll

      public static void saveOrUpdateAll(org.hibernate.Session session, @NotNull @NotNull Iterable<?> entities)
    • save

      @Deprecated public static void save(org.hibernate.Session session, Object object, Serializable id)
      Deprecated.
      since 5.8
      Saves the object with the supplied id.
    • deleteAll

      public static void deleteAll(org.hibernate.Session session, List<?> entities)
    • bindQueryParameters

      public static void bindQueryParameters(@NotNull @NotNull org.hibernate.query.Query query, @NotNull @NotNull Map<String,Object> params) throws org.hibernate.HibernateException
      Binds named parameters to the Query. For each Map.Entry, the key would be the parameter name and the value would be the value to bind.

      If the value is a Collection, it will be bound using Query.setParameterList(String, Collection).

      If the value is a Date, it will be bound using Query.setParameter(String, Object, Type).

      In any other case Query.setParameter(String, Object) will be used.

      Parameters:
      query - the query
      params - params to bind (values mapped by parameter names)
      Throws:
      org.hibernate.HibernateException
    • addRestrictionIn

      public static void addRestrictionIn(DbmsBean dbmsBean, org.hibernate.Criteria criteria, String propertyName, List<?> values)
      Adds a Restrictions.in(String, Collection) to criteria. On Oracle, adds multiple or-ed in conditions, each not exceeding 1000 components. Will fail on SQL Server if the amount of params exceeds 2000.
    • listCriteria

      public static List listCriteria(DbmsBean dbmsBean, Supplier<org.hibernate.Criteria> criteriaFactory, String propertyName, List<?> values)
      Sets the given query param and runs Criteria.list(). On Oracle, adds multiple or-ed in conditions, each not exceeding 1000 components. On SQL Server, runs the query as many times as needed, in batches of 1900 values.
    • listQuery

      public static List listQuery(DbmsBean dbmsBean, org.hibernate.query.Query query, String queryParam, List<?> values)
      Sets the given query param and runs Query.list(). On Oracle, runs the query as many times as needed, in batches of 1000 values.
    • listQuery

      public static List listQuery(DbmsBean dbmsBean, org.hibernate.query.Query query, String queryParam1, List<?> values1, String queryParam2, List<?> values2)
    • getMaximumNumberOfValuesForIn

      public static int getMaximumNumberOfValuesForIn(DbmsBean dbmsBean)
    • setId

      public static <T extends com.atlassian.core.bean.EntityObject> T setId(T bambooObject, long id)
      Sets the id on the supplied object and returns it.