wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roy van Rijn" <roy.van.r...@gmail.com>
Subject Re: Pagination Probelm with date_Sub(): MYSQL +HIberante
Date Mon, 03 Dec 2007 13:00:29 GMT
Not really a Wicket question... but as long as we answer :)

You can just use Date objects in Hibernate:

Criteria criteria = session.createCriteria(Sale.class);
if (startDate != null) {
	criteria.add(Expression.ge("date",startDate);
}
List results = criteria.list();

And in HQL you can do:

 Map parameters = new HashMap();
 StringBuffer queryBuf = new StringBuffer("from Sale s ");
 boolean firstClause = true;

 if (startDate != null) {
	  queryBuf.append(firstClause ? " where " : " and ");
	  queryBuf.append("s.date >= :startDate");
	  parameters.put("startDate",startDate);
	  firstClause = false;
 }

(examples from: http://www.javalobby.org/articles/hibernatequery102/)

Roy

On 12/3/07, wicketshafi <sm.shafi99@gmail.com> wrote:
>
>
> I am using wicket ,hibernate ...
>
> Use Case:  getting all the records which are created within 30 days....
>
> DATE_SUB(CURDATE(),INTERVAL 30 DAY) is giving error in hibernate....
> can any body help me  to solve this issue ....
>
> if you know hibernate date functions  regarding this issue..
> could you let me know once...
>
> regards
> Shafi
>
>
>
>
> --
> View this message in context: http://www.nabble.com/Pagination-Probelm-with-date_Sub%28%29%3A-MYSQL-%2BHIberante-tf4936098.html#a14128684
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Mime
View raw message