Jrcastro Ribeiro wrote:Thats my sql (working)
Jrcastro Ribeiro wrote:And thats the method im using:
Roel De Nijs wrote:
Jrcastro Ribeiro wrote:Thats my sql (working)
On which database is that statement valid SQL?
I would expect to see something likeAnd a similar condition if you want to check the endDate as well
Jrcastro Ribeiro wrote:Using Mysql
Jrcastro Ribeiro wrote:But I cannot relate these two columns to show the objects that begin on startDate and ends at endDate ?
Roel De Nijs wrote:
Jrcastro Ribeiro wrote:Using Mysql
Very hard to believe! The appropriate syntax of the BETWEEN operator is expr BETWEEN min AND max.
Jrcastro Ribeiro wrote:But I cannot relate these two columns to show the objects that begin on startDate and ends at endDate ?
Sure you can! But not with the BETWEEN operator. Just use startDate >= date1 AND endDate <= date2
Jrcastro Ribeiro wrote:Here the SS, seem to be working
Jrcastro Ribeiro wrote:Something like that?
And date 1 and date 2 are the parameter
Jrcastro Ribeiro wrote:It's saying that i cannot use the operator with this type of variable, but why?
Roel De Nijs wrote:
Jrcastro Ribeiro wrote:It's saying that i cannot use the operator with this type of variable, but why?
Because date1 and date2 are strings! Should be java.util.Date of course (like in your entity mapping).
So your method signature should be
Jrcastro Ribeiro wrote:But same problem =/ , really don't know what is wrong.
Roel De Nijs wrote:
Jrcastro Ribeiro wrote:But same problem =/ , really don't know what is wrong.
Very weird! Should normally work without any problem. If you google for "jpql date less than", you'll see this solution is used each time.
Just to be sure: can you try qualifying the properties in your JPQL query and add space before comparison operators? So using u.startDate >= :date1 and u.endDate <= :date2.
If it doesn't work, please share the stack trace as well.
Consider Paul's rocket mass heater. |