-->
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: adding Order to Columns by CaseNumber from another Table
PostPosted: Thu Dec 04, 2014 1:26 am 
Newbie

Joined: Wed Nov 19, 2014 6:00 am
Posts: 6
Please Help
How Can I add .addOrder(Order.desc("CaseNo,"of", CaseYear "));
I have two Tables Case_Master and Event_Master.

CaseId is foreign key in event_master .
I am fetching eventmasterlist from criteria query.
I wanted just to sort by Casenumber which is present in casemaster.(CaseNumber 1 of 2011)
order should be like this 1 of 2011 ,2of 2011,3 of 2011, 4 of 2011,5 of 2011
Criteria crt = session.createCriteria(merc.dao.EventMasterDao.class).add(Restrictions.eq("isDeleted", "N")).addOrder(Order.asc("eventDate"));
fetchList = (ArrayList<EventMasterDao>) crt.list();


Criteria crt = sess.createCriteria(merc.dao.CaseMasterDao.class).add(Restrictions.eq("isDeleted", "N"))
.addOrder(Order.desc("caseId"))
.addOrder(Order.asc("caseNo"))
.addOrder(Order.asc("caseYear"));
fetchList = (ArrayList<CaseMasterDao>) crt.list();


Last edited by asimshaikh1Hib on Thu Dec 04, 2014 2:04 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: adding Order to Columns by CaseNumber from another Table
PostPosted: Thu Dec 04, 2014 1:38 am 
Newbie

Joined: Wed Nov 19, 2014 6:00 am
Posts: 6
For Better UnderStanding I am sending my Query .I need Order by should change to
order by a.EventDate asc ,(f.CaseNo ," of ",g.YEAR) asc

select distinct a.*
from event_master a LEFT OUTER JOIN event_master_attachment b
ON (a.EventId = b.eventid and b.is_Deleted='N')
where a.isdeleted = 'N'
and a.status = 'Y'
and ( a.EventDesc like '%%'
or date_format(a.EventDate,'%a %d/%M/%Y %h:%i %p') like '%%'
or Case When a.EventStatusId = '1' then 'Scheduled' When a.EventStatusId = '2' then 'Completed' When a.EventStatusId = '3' then 'Rescheduled' When a.EventStatusId = '4' then 'Rescheduled till Further Notice' end like '%%'
or a.RescheduleEventId like '%%'
or b.event_attach_description like '%%'
or a.EventTypeId in (select g.eventtypeid
from event_type_master g
where g.eventTypename like '%%'
and g.status = 'Y'
and g.isdeleted = 'N')
or a.casesid in (select f.casesid
from case_master f, year_master g
where f.CaseYear=g.YEAR_ID
and f.isdeleted = 'N'
and f.status = 'Y'
and concat(f.CaseNo ," of ",g.YEAR) like '%%'))
order by a.EventDate asc


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.