Yes, there is, but how will be the syntax? 

On 2021/01/02 14:07:55, John Huss <johnth...@gmail.com> wrote: 
> Isn’t there a version of .exp that takes args? You can pass a date object
> directly there without worrying about formatting.
> 
> On Sat, Jan 2, 2021 at 7:49 AM Andrea Biasillo <a...@dataloy.com> wrote:
> 
> > Hi Mike!
> >
> >
> >
> > I have tried with:
> >
> >
> >
> > Expression expDate = ExpressionFactory.exp("modifiedDate>
> > TO_DATE('2003-07-17','yyyy-mm-dd')");
> >
> >
> >
> > but I get this exception:
> >
> >
> >
> > Caused by: org.apache.cayenne.exp.ExpressionException: [v.4.2.M1 Nov 26
> > 2020 09:20:26] Encountered " "(" "( "" at line 1, column 22.
> >
> > Was expecting one of:
> >
> >     <EOF>
> >
> >     "or" ...
> >
> >     "and" ...
> >
> >     "|" ...
> >
> >     "^" ...
> >
> >     "&" ...
> >
> >     "<<" ...
> >
> >     ">>" ...
> >
> >     "+" ...
> >
> >     "-" ...
> >
> >     "/" ...
> >
> >     "*" ...
> >
> >
> >
> > and I really would want to have all my expression in one string, without
> > use greaterExp.
> >
> > Like this:
> >
> >
> >
> > Expression exp = ExpressionFactory.exp("businessPartnerName='andrea' and
> > businessPartnerCode!='rossi' or ((businessPartnerCode!='bianchi' and
> > maxAdvancePaymentPercent>9) or businessPartnerCode!='pippo' or
> > (maxAdvancePaymentPercent>100 or maxAdvancePaymentPercent<10)) and
> > modifiedDate> TO_DATE('2003-07-17','yyyy-mm-dd')");
> >
> >
> >
> > But maybe it is not possible.
> >
> >
> >
> > Andrea
> >
> >
> >
> > On 2021/01/02 12:45:49, Mike Kienenberger <mkien...@gmail.com> wrote:
> >
> > > Oracle expects SQL like the following to compare dates.
> >
> > >
> >
> > >        MODIFIED_DATE > TO_DATE('2003-07-17','yyyy-mm-dd')
> >
> > >
> >
> > > You either need to use that in your exp() method, or use greaterExp(),
> >
> > > which can automatically generate the needed sql for the current database.
> >
> > >
> >
> > >         Date date = new GregorianCalendar(2003, Calendar.JULY,
> >
> > > 17).getTime() ;
> >
> > >         Expression matchDateGreaterThanDate1 =
> >
> > > ExpressionFactory.greaterExp("MODIFIED_DATE", date);
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > > On Sat, Jan 2, 2021 at 3:45 AM Andrea Biasillo <a...@dataloy.com> wrote:
> >
> > >
> >
> > > > Hi!
> >
> > > >
> >
> > > > Is it possible to use Date values in ExpressionFactory.exp?
> >
> > > >
> >
> > > > This works very well:
> >
> > > >
> >
> > > > Expression exp = ExpressionFactory.exp("businessPartnerName='andrea'
> > and
> >
> > > > businessPartnerCode!='rossi' or ((businessPartnerCode!='bianchi' and
> >
> > > > maxAdvancePaymentPercent>9) or businessPartnerCode!='pippo' or
> >
> > > > (maxAdvancePaymentPercent>100 or maxAdvancePaymentPercent<10))");
> >
> > > >
> >
> > > > but if I use a Date value like this:
> >
> > > >
> >
> > > > Expression expDate = ExpressionFactory.exp("modifiedDate>
> > '2003-07-17'");
> >
> > > >
> >
> > > > The database, Oracle in my case, will complain:
> >
> > > >
> >
> > > > Literal does not match format string
> >
> > > > (the database expects something like this:  MODIFIED_DATE > DATE
> >
> > > > '2003-07-17')
> >
> > > >
> >
> > > > Any input?
> >
> > > >
> >
> > > > Andrea
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > >
> >
> >
> 

Reply via email to