I am trying to write oracle subquery in Hibernate criteria but unable to do it. Can anyone help me to achieve this. Below is my oracle query.
SELECT a.id,
b.address
FROM tableA a
INNER JOIN TABLE b
ON a.id = b.id
WHERE mainId IN
(SELECT bp.ptyID
FROM bpTable bp,
busHeaderbh bh
WHERE bh.aid = bp.aid
AND bh.parentBID IN
(SELECT bp.ptyID
FROM bpTable bp,
busHeaderbh bh
WHERE bh.aid = bp.aid
AND bh.parentBID = 123
UNION
SELECT 123 FROM dual
)
UNION
SELECT 123 FROM dual
)
AND
GROUP BY a.id,
b.credttm
ORDER BY a.id DESC;
Thanks in Advance.
I have written one example for one to many relationship table you can get reference from it
Criteria person = session.getCurrentSession().createCriteria(Person.class).createAlias("personId", "personId");
person.add(Restrictions.disjunction().add(Restrictions.ilike("PersonFirstname",Search,MatchMode.ANYWHERE))
.add(Restrictions.ilike("personId.prop1",Search,MatchMode.ANYWHERE))
.add(Restrictions.ilike("personId.col1",Search,MatchMode.ANYWHERE))
.addOrder(Property.forName("colName").desc()
.addOrder(Property.forName("colName").asc());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.