Class HibernateDaoUtils
java.lang.Object
com.atlassian.bamboo.persistence3.HibernateDaoUtils
A variety of methods useful when interacting with DAO objects.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
static 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
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
saveOrUpdate
(@NotNull org.hibernate.Session session, BambooObject entity) static void
saveOrUpdateAll
(org.hibernate.Session session, @NotNull Iterable<?> entities) static <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 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
-
copyTimestamp
-
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.since 5.8Saves the object with the supplied id. -
deleteAll
-
bindQueryParameters
public static void bindQueryParameters(@NotNull @NotNull org.hibernate.query.Query query, @NotNull @NotNull Map<String, Object> params) throws org.hibernate.HibernateExceptionBinds 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
-
getMaximumNumberOfValuesForIn
-
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.
-