0

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.

Marmite Bomber
  • 19,886
  • 4
  • 26
  • 53
user1127643
  • 169
  • 4
  • 12

1 Answers1

0

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());
мalay мeнтa
  • 125
  • 3
  • 11