-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: if condition in hibernate query
PostPosted: Mon Mar 26, 2007 8:08 am 
Newbie

Joined: Mon Mar 26, 2007 7:50 am
Posts: 1
Hi, I am a novice in Hibernate field.

I have a SQL query like

select distinct atd.docID, atd.Doctitle,col.collectionName, atm.ActionPerformed,atm.ActionDateTime,atm.UserID,
(Case when atd.totalNoOfAccess = -1 then a.TotalNoOfAccess else atd.totalNoOfAccess end)TotalNoOfAccess,
(Case when atd.DocID not in (Select DocID from TblDocMasterIdentification) then 'Deleted' else dmi.status end)CurrentStatus

from TblAuditTrailMaster atm ,TblAuditTrailDoc atd, TblCollections col,tblDocInformation a,TblDocMasterIdentification dmi

where atm.AuditID = atd.AuditID and atd.CollectionID = col.CollectionID and atd.docID = dmi.docID and atd.docID = a.docID and atm.AuditID in

(select max(atm.AuditID) from TblAuditTrailMaster atm )


i want to convert this into hibernate query. i know its a bit complex, but i want to know how can i add if condition like case in SQL for conditional selection in hibernate


some one pls help.....
Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 27, 2007 12:11 pm 
Beginner
Beginner

Joined: Sun Nov 16, 2003 3:04 pm
Posts: 24
Not that I've tried case, specifically, but most hql queries, unless you use ?'s or :'s, the sql will pass through to the end.

Doing a case in a criteria object, though, may not be possible.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.