You can do this like in the following code I did.
There are Restrictions in Restrictions.
If you want to distinct the result add the last statement.
// ** begin
criteria = session.createCriteria().add(
Restrictions.or(
// startpoint in value
(Restrictions.and(Restrictions.ge(startpoint, recort.getStart() ), (Restrictions.le(startpoint, record.getStop() ) ))),
//endpoint in value
(Restrictions.and(Restrictions.gt(endpoint, record.getStart() ),
(Restrictions.lt(endpoint, record.getEnd()) )))
)
);
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
// ** end
I hope I could help you.
Kind regards
Martin
|