Hello Friends,
I am new to hibernate and this forum. I would really appreciate if someone could help me solve the problem.I have a sql query
Code:
select p.id, p.start, p.end from purchase p, account a where p.eid =940 and p.id=a.id and a.status = 'reference';
I learnt from the tutorials, for the sql query below the following is the criteria query
Code:
SELECT B.*,P.* FROM BANK B, PURCHASE P WHERE B.ACCNO=P.ACCNO;
Code:
List rs = session.createCriteria(Bank.class)
.setFetchMode("Purchase",FetchMode.JOIN)
.list();
So for my sql statement can someone please tell me if my criteria query is right?
Code:
List rs = session.createCriteria(purchase.class)
.setFetchMode("account",FetchMode.JOIN)
.add(Restrictions.eq("eid",new Integer(940)
.add(Restrictions.eq("status","reference")
.setProjection(Projections.propertyList()
.add(Projections.property("id"))
.add(Projections.property("start"))
.add(Projections.property("end"))
.list();
Thanks in advance