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 Summary
Fields Modifier and Type Field Description static int
ORACLE_MAXIMUM_NUMBER_OF_VALUES_FOR_IN_QUERY
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addRestrictionIn(DbmsBean dbmsBean, org.hibernate.Criteria criteria, String propertyName, List<?> values)
Adds aRestrictions.in(String, Collection)
to criteria.static void
bindQueryParameters(@NotNull org.hibernate.query.Query query, @NotNull Map<String,Object> params)
Binds named parameters to theQuery
.static void
copyTimestamp(BambooObject from, BambooObject to)
static void
deleteAll(org.hibernate.Session session, List entities)
static <E extends BambooObject>
Eexecute(@NotNull org.springframework.orm.hibernate5.support.HibernateDaoSupport dao, @NotNull org.springframework.orm.hibernate5.HibernateCallback action)
Deprecated.since 5.12, use session objects directlystatic boolean
exists(@NotNull org.springframework.orm.hibernate5.support.HibernateDaoSupport dao, @NotNull org.springframework.orm.hibernate5.HibernateCallback action)
Deprecated.since 5.12, use session objects directlystatic int
getMaximumNumberOfValuesForIn(DbmsBean dbmsBean)
static List
listCriteria(DbmsBean dbmsBean, Supplier<org.hibernate.Criteria> criteriaFactory, String propertyName, List<?> values)
Sets the given query param and runsCriteria.list()
.static List
listQuery(DbmsBean dbmsBean, org.hibernate.query.Query query, String queryParam, List<?> values)
Sets the given query param and runsQuery.list()
.static List
listQuery(DbmsBean dbmsBean, org.hibernate.query.Query query, String queryParam1, List<?> values1, String queryParam2, List<?> values2)
static void
save(org.hibernate.Session session, Object object, Serializable id)
Deprecated.since 5.8static void
save(org.springframework.orm.hibernate5.HibernateOperations hibernateOperations, Object object, Serializable id)
Deprecated.since 5.8static void
saveAll(@NotNull org.springframework.orm.hibernate5.support.HibernateDaoSupport dao, Collection<? extends BambooObject> entities)
Deprecated.since 5.12, usesaveOrUpdateAll(Session, Iterable)
static void
saveOrUpdate(@NotNull org.hibernate.Session session, BambooObject entity)
static void
saveOrUpdate(@NotNull org.springframework.orm.hibernate5.support.HibernateDaoSupport dao, BambooObject entity)
Deprecated.since 5.12, usesaveOrUpdate(Session, BambooObject)
static void
saveOrUpdateAll(org.hibernate.Session session, @NotNull Iterable<?> entities)
static void
saveOrUpdateAll(org.springframework.orm.hibernate5.HibernateOperations hibernateTemplate, Iterable<?> entities)
Deprecated.since 5.12, useHibernateTemplate.execute(HibernateCallback)
static <T extends BambooObject>
com.google.common.base.Function<T,T>saveOrUpdateFunction(@NotNull org.springframework.orm.hibernate5.HibernateTemplate hibernateTemplate)
Deprecated.since 5.12, use Java 8 features insteadstatic <T extends com.atlassian.core.bean.EntityObject>
TsetId(T bambooObject, long id)
Sets the id on the supplied object and returns it.static void
updateTimestamp(BambooObject bambooObject)
-
-
-
Field Detail
-
ORACLE_MAXIMUM_NUMBER_OF_VALUES_FOR_IN_QUERY
public static final int ORACLE_MAXIMUM_NUMBER_OF_VALUES_FOR_IN_QUERY
- See Also:
- Constant Field Values
-
-
Method Detail
-
updateTimestamp
public static void updateTimestamp(BambooObject bambooObject)
-
copyTimestamp
public static void copyTimestamp(BambooObject from, BambooObject to)
-
saveOrUpdate
@Deprecated public static void saveOrUpdate(@NotNull @NotNull org.springframework.orm.hibernate5.support.HibernateDaoSupport dao, BambooObject entity)
Deprecated.since 5.12, usesaveOrUpdate(Session, BambooObject)
-
saveOrUpdate
public static void saveOrUpdate(@NotNull @NotNull org.hibernate.Session session, BambooObject entity)
-
saveAll
@Deprecated public static void saveAll(@NotNull @NotNull org.springframework.orm.hibernate5.support.HibernateDaoSupport dao, Collection<? extends BambooObject> entities)
Deprecated.since 5.12, usesaveOrUpdateAll(Session, Iterable)
-
saveOrUpdateAll
public static void saveOrUpdateAll(org.hibernate.Session session, @NotNull @NotNull Iterable<?> entities)
-
saveOrUpdateAll
@Deprecated public static void saveOrUpdateAll(org.springframework.orm.hibernate5.HibernateOperations hibernateTemplate, Iterable<?> entities) throws org.springframework.dao.DataAccessException
Deprecated.since 5.12, useHibernateTemplate.execute(HibernateCallback)
- Throws:
org.springframework.dao.DataAccessException
-
execute
@Deprecated @Nullable public static <E extends BambooObject> E execute(@NotNull @NotNull org.springframework.orm.hibernate5.support.HibernateDaoSupport dao, @NotNull @NotNull org.springframework.orm.hibernate5.HibernateCallback action) throws org.springframework.dao.DataAccessException
Deprecated.since 5.12, use session objects directly- Throws:
org.springframework.dao.DataAccessException
-
exists
@Deprecated public static boolean exists(@NotNull @NotNull org.springframework.orm.hibernate5.support.HibernateDaoSupport dao, @NotNull @NotNull org.springframework.orm.hibernate5.HibernateCallback action) throws org.springframework.dao.DataAccessException
Deprecated.since 5.12, use session objects directly- Throws:
org.springframework.dao.DataAccessException
-
save
@Deprecated public static void save(org.springframework.orm.hibernate5.HibernateOperations hibernateOperations, Object object, Serializable id)
Deprecated.since 5.8Saves the object with the supplied id.
-
save
@Deprecated public static void save(org.hibernate.Session session, Object object, Serializable id)
Deprecated.since 5.8Saves the object with the supplied id.
-
deleteAll
public static void deleteAll(org.hibernate.Session session, List entities)
-
saveOrUpdateFunction
@Deprecated public static <T extends BambooObject> com.google.common.base.Function<T,T> saveOrUpdateFunction(@NotNull @NotNull org.springframework.orm.hibernate5.HibernateTemplate hibernateTemplate)
Deprecated.since 5.12, use Java 8 features instead
-
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 theQuery
. For eachMap.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 usingQuery.setParameterList(String, Collection)
.If the value is a
Date
, it will be bound usingQuery.setParameter(String, Object, Type)
.In any other case
Query.setParameter(String, Object)
will be used.- Parameters:
query
- the queryparams
- 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 aRestrictions.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 runsCriteria.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 runsQuery.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.
-
-