Hibernate Criteria: Add restrictions to Criteria and DetachedCriteria
Posted
by Gilean
on Stack Overflow
See other posts from Stack Overflow
or by Gilean
Published on 2010-04-08T03:46:05Z
Indexed on
2010/04/08
3:53 UTC
Read the original article
Hit count: 631
Currently our queries add a variety of Restrictions to ensure the results are considered active or live. These Restrictions are used in several places/queries so a method was setup similar to
public Criteria addStandardCriteria(Criteria criteria, ...) {
// Add restrictions, create aliases based on parameters
// and other non-trivial logic
criteria.add(...);
return criteria;
}
This has worked fine so far, but now this standard criteria needs to be added to a subquery using DetachedCriteria. Is there a way to modify this method to accept Criteria or DetachedCriteria or a Better way to add restrictions?
© Stack Overflow or respective owner