Hi Peter,

Thanks for your reply. I'm pretty sure I tried to do something like that originally but still had errors like those I reported originally

where my expression was something like (I can't remember exactly what I had)

           String anExp = "groupId = " + identity +
                          " and status < 2" +
                          " and date(dtAppointment) = '$date'" ;
           Expression exp = Expression.fromString(anExp);
exp = exp.expWithParameters(Collections.singletonMap("date", new SimpleDateFormat("yyyyMMdd").format(item.getTime()))); SelectQuery qAppointments = new SelectQuery(Appointments.class, exp);
)


I have since worked around the problem by using the following statements - which work but seems to me to defeat the purpose of using Cayenne. I'm sure it's my lack of understanding on how to effectively use Cayenne and not the capabilities of Cayenne!!

           String anExp = "groupId = " + identity +
                          " and status < 2" +
                          " and dtAppointment >= '" +
new SimpleDateFormat("yyyyMMdd 00:00:00").format(item.getTime()) + "'" +
                          " and dtAppointment <= '" +
new SimpleDateFormat("yyyyMMdd 23:59:59").format(item.getTime()) + "'";
           Expression exp = Expression.fromString(anExp);
SelectQuery qAppointments = new SelectQuery(Appointments.class, exp);

Andrew


Peter Schröder wrote:
hi andrew,

i am not totally clear about that, but afaik you may not use that date() 
function in your expression. cayenne will put the right string of a date object 
to your query, if you pass a date as a parameter.
take a look at named parameter expressions: 
http://cayenne.apache.org/doc20/building-expressions.html


@andrus: on http://cayenne.apache.org/doc20/expressions.html there is still a 
broken link to BNF expression language!


Reply via email to