-->
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: Criteria sentence to find dates between today
PostPosted: Tue Jun 27, 2017 4:42 am 
Newbie

Joined: Tue Jun 27, 2017 4:34 am
Posts: 1
Hi everybody,

I need to find the result of two dates when today's date is between them.

Date fechahoy = new Date();
MClientesMTarifas mcmt = (MClientesMTarifas) getSession().createCriteria(MClientesMTarifas.class)
.add(Restrictions.eq("idcliente_cliente", idcliente))
.add(Restrictions.between(today, "fechainicio", "fechafin"))
.uniqueResult();

And I get this error:
GRAVE: org.hibernate.QueryException: could not resolve property: today of: org.dpsistem.spring.model.cliente.MClientesMTarifas

How can I get this result???

Thanks.


Top
 Profile  
 
 Post subject: Re: Criteria sentence to find dates between today
PostPosted: Tue Jun 27, 2017 5:20 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The way you call the between method:

Code:
.add(Restrictions.between(today, "fechainicio", "fechafin"))


Does not match the way it was intended to be used. Follow the method signature and the match the parameters accordingly:

Code:
public static Criterion between(String propertyName, Object low, Object high) {
    return new BetweenExpression( propertyName, low, high );
}


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.