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.  [ 1 post ] 
Author Message
 Post subject: ICriteria Query XML configuration
PostPosted: Tue Apr 15, 2008 4:59 am 
Newbie

Joined: Fri Apr 04, 2008 5:34 am
Posts: 8
I have to do a batch to send daily mails to the clients if is their birthday. I don't know how to get the day and month from database and compare with datetime.now. day and datetime.now.month . In the database I have one column date_naissance Date, and I have 2 fields to compare in my query. I don't know how to configure the xml file. I've tried 2 methods...but it didn't work.

First method:

Code:
BaseDataAccess bda = new BaseDataAccess();
ICriteria crit = bda.CreateCriteria(typeof(Client));
crit.Add(Expression.Eq("DataNM",DateTime.Now.Month));
crit.Add(Expression.Eq("DataNJ",DateTime.Now.Day));
return crit.List() as ArrayList();




The second method:
Code:
string str = "FROM client WHERE MONTH(date_naissance) = MONTH(NOW()) AND DAYOFMONTH(date_naissance) = DAYOFMONTH(NOW())";
IQuery qry= NHibernateHttpModule.CurrentSession.CreateQuery(str);

//I've tried this too...IQuery qry = bda.CreateQuery(str) as IQuery;

return qry.List() as ArrayList;


For the second method I have this message:


Quote:
in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [FROM client WHERE MONTH(date_naissance) = MONTH(NOW()) AND DAYOFMONTH(date_naissance) = DAYOFMONTH(NOW())]



I'm sure that the xml file it's not configured well but I don't know how to do it. Pls help...


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

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.